Program on single and double pointer
#include <stdio.h>
void main()
{
int x=4,y,z;
int *sp;
int **dp;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
sp=&x;
printf("\n y value is %p",sp);
printf("\n y address is %p",&sp);
dp=&sp;
printf("\n z value is %p",dp);
printf("\n z address is %p",&dp);
*sp+=1;
y=*sp;
printf("\n y value is %d",y);
**dp+=3;
z=**dp;
printf("\n z value is %d",z);
printf("\n value of x+y+z =%d",(x+y+z));
}
output:
#include <stdio.h>
void main()
{
int x=4,y,z;
int *sp;
int **dp;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
sp=&x;
printf("\n y value is %p",sp);
printf("\n y address is %p",&sp);
dp=&sp;
printf("\n z value is %p",dp);
printf("\n z address is %p",&dp);
*sp+=1;
y=*sp;
printf("\n y value is %d",y);
**dp+=3;
z=**dp;
printf("\n z value is %d",z);
printf("\n value of x+y+z =%d",(x+y+z));
}
output:
No comments:
Post a Comment