#include<stdio.h>
void read(int a[50],int n);
void display(int a[50],int n);
void reverse(int a[50],int n);
int main()
{
int a[50],n;
printf("Enter the size of the array\n");
scanf("%d",&n);
printf("Enter the array elements\n");
read(a,n);
printf("The array elements are:\n");
display(a,n);
reverse(a,n);
}
void read(int a[50],int n)
{
int i;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
}
void display(int a[50],int n)
{
int i;
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
}
void reverse(int a[50],int n)
{
int i;
printf("\nThe reverse of the array is:\n");
for(i=n-1;i>=0;i--)
{
printf("%d\t",a[i]);
}
}
Output:
Comments
Post a Comment