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.

Leave a Comment

Your email address will not be published. Required fields are marked *

To Resolve this issue at just 5$ from ServerExpert

https://serverexpert.io/

For Hosting please visit Hostingwebsite.io

You have Successfully Subscribed!

Open chat