C File =>
/* Write a program to display the elements of an array containing n integers in the reverse order using a pointer to the array.*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr,arr[30],n,i;
printf("\n Enter value of n : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n Enter array element%d ",i+1);
scanf("%d",&arr[i]);
}
//moving pointer at last element
ptr=&arr[n-1];
printf("\n Array elements in reverse :\n");
for(i=0;i<n;i++)
{
printf("%d\t",*ptr);
ptr=ptr-1;
}
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in message.