Code:
#include<stdio.h>
#define MAX 50
void read(int a[MAX], int n);
void display(int a[MAX],int n);
void reverse(int a[MAX],int n);
int main()
{
int n, a[MAX];
printf(“Enter array size :”);
scanf(“%d”,&n);
read(a,n);
display(a,n);
reverse(a,n);
return 0;
}
//Chetan Shidling
void read(int a[MAX], int n)
{
int i;
printf(“Enter the array elements\n”);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
}
void display(int a[MAX],int n)
{
int i;
printf(“Array elements are\n”);
for(i=0;i<n;i++)
printf(“%d\n”,a[i]);
}
//CS Electrical & Electronics
void reverse(int a[MAX],int n)
{
int i,j,b[MAX];
for(i=n-1,j=0;i>=0;i–,j++)
b[j]=a[i];
for(i=0;i<n;i++)
a[i]=b[i];
printf(“Reverse array is\n”);
for(i=0;i<n;i++)
printf(“%d\n”,a[i]);
}
Output:
Enter array size :5
Enter the array elements
12
22
123
23
2
Array elements are
12
22
123
23
2
Reverse array is
2
23
123
22
12