c program to determine the memory location of a variable using pointer

As you know pointer contains the memory location of another variable her in the source code given below num is variable and *pnum is pointer storing the variable of num

source code:

#include<stdio.h>
int main()
{
int num,*pnum;
pnum=&num;
printf("Enter the number ");
scanf("%d",&num);
printf("\n The number that was entered is %d",num);
printf("\n the address of memory location is %u");
return 0;
}

output:
Enter the number 10

 The number that was entered is 10
 the address of memory location is 2147483612

%p string prints the argument as a memory address in hexadecimal form .%u will print in decimal.

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation