Program
#include <stdio.h>
int cal(int);
int main()
{
int n;
printf("Enter the number of elements in array\n");
scanf("%d", &n);
cal(n);
}
int cal(int n)
{
int c, d, a[100], b[100];
printf("Enter the array elements\n");
for (c = 0; c < n ; c++)
scanf("%d", &a[c]);
for (c = n - 1, d = 0; c >= 0; c--, d++)
b[d] = a[c];
for (c = 0; c < n; c++)
a[c] = b[c];
printf("Reverse array is\n");
for (c = 0; c < n; c++)
printf("%d\n", a[c]);
return 0;
}
Output:
Enter the number of elements in array
5
Enter the array elements
8
3
9
5
7
Reverse array is
7
5
9
3
8
0 Comments