Become Our Fan on Social Sites!

Facebook Twitter

Google+ RSS YouTube

Friday 11 October 2013

Reverse Integer Array Without Using Another Array

C program for reverse integer array without using another array that means swapping values.



 #include<stdio.h>  
 int main()  
 {  
   int arr1[] = {5,6,2,4,7,1,3,8,9,0}, i;  
   clrscr();  
   for(i=0; i<10; i++)  
     printf("%d ",arr1[i]);  
   printf("\n");  
   for(i=0; i<10/2; i++)  
   {  
     int temp = arr1[i];  
     arr1[i] = arr1[10-i-1];  
     arr1[10-i-1] = temp;  
   }  
   for(i=0; i<10; i++)  
     printf("%d ",arr1[i]);  
   return 0;  
 }  

0 comments :

Post a Comment