Pointer Program in C

Pointer Program in C

//pointer a special type of variable which store address of another varable(referencing like p=&a). and by pointer de-referncing that varible a by *p

#include<stdio.h>

main()
{

  int a=100;     //simple variable
  int *p;       //pointer p special variable which store another variable address
   p=&a;
 
  printf("\n%d\n",a);       //value of a

   printf("%d\n\n",*p);          //print value at address of a..which is 100
   printf("%d\n\n",*p);         //print value at address of a..which is 100


     printf("%p\n",p);         //address of p("%p", is format spicifier for prnting address.we also use "%x", or "%u", but in c "%p", is specialy for printing address)

      printf("%p\n\n",&a);     //address of a  
       
 }

Related Posts