//WAP TO SHOW THE FUNCTIONING OF POINTER TO A POINTER
#include<conio.h>
#include<stdio.h>
void main()
{
int a=10;
int *ptr;
int **ptr2;
ptr=&a;
ptr2=&ptr;
clrscr();
printf("\n\nVALUE STORED AT A=%d",a);
printf("\n\nADDRESS OF A=%u",&a);
printf("\n\nVALUE STORED AT PTR(ADDRESS OF A)=%u",ptr);
printf("\n\nVALUE POINTED BY PTR(VALUE OF A)=%d",*ptr);
printf("\n\nADDRESS OF PTR=%u",&ptr);
printf("\n\nVALUE STORED AT PTR2(ADDRESS OF PTR)=%u",ptr2);
printf("\n\nVALUE POINTED BY PTR2(THE VALUE WHICH IS POINTED BY PTR I.E, VALUE OF A)=%d",**ptr2);
printf("\n\nADDRESS OF PTR2=%u",&ptr2);
printf("\n\nTHE VALUE GIVES BY PTR2 WHEN THERE IS A SINGLE ASTRIX=%u=VALUE OF A",*ptr2);
getch();
}
/***********************************************************************************************
OUTPUT
***********************************************************************************************
VALUE STORED AT A=10
ADDRESS OF A=65524
VALUE STORED AT PTR(ADDRESS OF A)=65524
VALUE POINTED BY PTR(VALUE OF A)=10
ADDRESS OF PTR=65522
VALUE STORED AT PTR2(ADDRESS OF PTR)=65522
VALUE POINTED BY PTR2(THE VALUE WHICH IS POINTED BY PTR I.E, VALUE OF A)=10
ADDRESS OF PTR2=65520
THE VALUE GIVES BY PTR2 WHEN THERE IS A SINGLE ASTRIX=65524=VALUE OF A
*/
No comments:
Post a Comment