Demonstration Of Pointer Arithmetic

 #include <stdio.h>


int main(void) 

{

  char c='A',*p;

  int i =5,*q;

  float f=3.5,*r;

  p=&c;

  q=&i;

  r=&f;

  printf("The value of c = %c\n",c);

  printf("The value of i = %d\n",i);

  printf("The value of f = %f\n",f);

  printf("The address of c is %u\n",p);

  printf("The address of i is %u\n",q);

  printf("The address of f is %u\n",r);

 

  p++;

  q++;

  r++;

  printf("\n value of address after increment");

   printf("\nThe address of c is %u\n",p);

  printf("The address of i is %u\n",q);

  printf("The address of f is %u\n",r);

  p--;

  q--;

  r--;

  printf("\n value of address after decrement");

  printf("\nThe address of c is %u\n",p);

  printf("The address of i is %u\n",q);

  printf("The address of f is %u\n",r);

}

Comments

Popular Posts