Problem Description
program using pointers to read in an array of integers and print its elements in reverse orderCODING ARENA::
#include <stdio.h>
int main()
{
int a[100],n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=n-1;i>=0;i--)
{
printf("%d ",a[i]);
}
return 0;
}
Test Case 1
Input (stdin)2 1 2
Expected Output2 1
Test Case 2
Input (stdin)5 1 2 6 8 5
Expected Output5 8 6 2 1
No comments:
Post a Comment