A C declaration codes below int print x and the memory map s
Solution
In first scenario:
int *p;
int x;
then , &p will give the address of p i.e = 2000
p gives you the address in memory where value of *p is located(random memory address same as &x)
*p gives the value pointed by p(here random value)
&x gives the address pf x(random memory address)
x is the value stored(some random value)
Scenario 2:
x=50;
&p=2000(address of p)
p=0xbfe8cd5c(some random memory address same as &x)
*p will give some random number because it is not made to point some specific value
&x=0xbfe8cd5c(random memory address)
x=50
when we declare: p=&x;
&p=2000(address of p)
p=0xbfe8cd5c(some random memory address same as &x)
*p=50(value to which it is made to point)
&x=0xbfe8cd5c(random memory address)
x=50
when we write: *p=38
&p=2000(address of p)
p=0xbfe8cd5c(some random memory address same as &x)
*p =38
&x=0xbfe8cd5c(random memory address)
x=38
