Reverse an array - C Program

C program to reverse an array.

Solution:

#include <stdio.h>
int main()
{
     int a[5], rev[5], i, j;   
     printf("Enter 5 Numbers:\n\n");
     for(i=0; i<5; i++)
          scanf("%d", &a[i]);
     printf("\nElements in Array:\n\n");
     for(i=0; i<5; i++)
          printf(" %d",a[i]);
     j=0;
     for(i=4; i>=0; i--)
     {
          rev[j] = a[i];
          j++;
     }
     /* Prints the reversed array*/
     printf("\n\nReversed array is : ");
     for(i=0; i<5; i++)
          printf("%d ", rev[i]);
     return 0;
}


Output:

reverse array