Get Update on recent Technology & Programming

Friday, 10 November 2017

C Program to reverse the elements of an array

Posted by   on Pinterest




C Program to reverse the elements of an array


#include<stdio.h>

int main(void)

{

 int i,j,temp,arr[10] = {1,2,3,4,5,6,7,8,9,10};

 for(i=0,j=9; i<j; i++,j--)

 {

  temp=arr[i];

  arr[i]=arr[j];

  arr[j]=temp;

 }

 printf("After reversing, the array is : ");

 for(i=0; i<10; i++)

  printf("%d  ",arr[i]);

 printf("\n");

 return 0;

}





No comments:
Write comments

Hey, we've just launched a new custom color Blogger template. You'll like it -
Join Our Newsletter