programming-examples/c/Arrays/C program to Reverse an array.c
2019-11-15 12:59:38 +01:00

25 lines
543 B
C

/* Reverse an array*/
#include<stdio.h>
#define MAX 100
void main()
{
int arr[MAX],n,i,temp;
printf("Enter size of Array: ");
scanf("%d",&n);
printf("Enter %d elements\n",n);
for(i=0; i<n; i++)
{
scanf("%d",&arr[i]);
}
for(i=0; i<n/2; i++)
{
temp=arr[i];
arr[i]=arr[n-i-1];
arr[n-i-1]=temp;
}
printf("Array after reversing : ");
for(i=0; i<n; i++)
{
printf("%d\t\n",arr[i]);;
}
}