Contact Learn C
Copy Program Share Program

Program 193:To Print values in array by Decrementing Pointer

Program 193:
 
#include<stdio.h>
main()
{
  int i,*ptr,max;
  printf("Enter number of values\n");
  scanf("%d",&max);
  int num[max-1];
  printf("Enter values for array\n");
  for(i=0;i<max;i++)
  {
   scanf("%d",&num[i]); 
  }
  
  ptr=&num[max-1];
  
  printf("Values printed by decrementing pointer\n");
  for(i=0;i<max;i++)
  {
   printf("%d\n",*ptr);
   ptr--;
  }
  
  
}

Explanation:

//Coming Soon...

Output:








 

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide