Program to reverse an array - C Program

Program to reverse an array

C program to reverse an array: This program reverses the array elements

#include <stdio.h>
int main()
{
 int num[5],size=5,i,j,temp;
 
 printf("enter %d elements of array : ",size);
 for(i=0;i<size;i++) 
    scanf("%d",&num[i]);
 for(i=0,j =size-1;i<size/2;i++,j--)
 {
          temp=num[i];
          num[i]=num[j];
          num[j]=temp;
 }


 printf("Array Element After Reverse....\n");
 for(i=0;i<size i++)
	printf("%d ",num[i]);

 return 0;
}

Output - Program to reverse an array

Enter 5 elements of array : 10 20 30 40 50                                                                            
Array Element After Reverse....                                                                                       
50 40 30 20 10              
Compile and Run Online