Various Methods of printing address & value of a variable along with pointers

#include<stdio.h>
main()
{
int a,b,*c,*d,e,f;
printf("Enter values of 2 variables a & b\n");
printf("Value of a:");
scanf("%d",&a);
printf("Value of b:");
scanf("%d",&b);
printf("Printing Address\nMethod I:\nAddress of a= %u, Address of b=%u\n",&a,&b);
c=&a;
d=&b;
printf("Method II:\nAddress of a= %d, Address of b=%d\n",c,d);
printf("Printing Value\nMethod I:\nValue of a = %d, Value of b = %d\n",a,b);
printf("Method II:\nValue of a = %d, Value of b = %d",*c,*d);

}

 

Output:

Output

Leave a Reply

Your email address will not be published.