/* Reversal of Array : Take a array as input from the user and print the array in reverse order. */
#include <stdio.h>
int main()
{
int n;
printf("Enter number of elements in array: ");
scanf("%d", &n);
int a[n], i;
for(i = 0; i < n; i++){
printf("Enter element %d: ", i+1);
scanf("%d", &a[i]);
}
printf("Printing the array you entered.....\n");
for(i = 0; i < n; i++)
printf("%d ", a[i]);
printf("\nPrinting the array in reverse order.....\n");
for(i = n-1; i >= 0; i--)
printf("%d ", a[i]);
return 0;
}
Comments
Post a Comment