Right Click to Search

Tuesday, December 29, 2024

Reversing of the Array Elements in C Programming


#include
#include
void main()
{
 int a[30],i,j,n,temp;
 printf("\n Enter no of elements :");
 scanf("%d",&n;);
 /* read n elements in an array  */
 for(i=0 ; i < n ; i++)
  scanf("%d",&a;[i]);
 j = i-1;   // j will Point to last Element
 i = 0;     // i will be pointing to first element 
 while(i < j)
 {
 temp = a[i];
 a[i] = a[j];
 a[j] = temp;
 i++;             // increment i and decrement j 
 j--;
 }
  /* Print out the Result of Insertion */
  for(i = 0 ;i< n ;i++)
  printf("\n %d",a[i]);
   getch();
}
Bookmark & Share

Tags / Keywords : |

Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email

 

Learn C Programming Copyright © 2010 LKart Theme is Designed by Lasantha, Free Blogger Templates