C Program to print array reverse using pointer

Simple C program to print array reverse: Address of first element of array is given by the name of array. For example if array is arr[3]={1,2,3} then arr is the address of element 1.
 
/* C program to print array reverse */
#include<stdio.h>
int main()
{
 /* Size of array is n */
 int n=7;
 int i,arr[7]={12,54,23,76,34,98,21};
 int *ptr=arr;
 for(i=1;i<7;i++)
 {
  ptr++;
 }
 for(;ptr>=arr;ptr--)
 {
  printf("%d ",*ptr);
 }
 return 0;
}
/* End of the program */
 


Popular posts from this blog