Address locations are usually represented with variable names. All the program must be loaded to memory, called RAM before execution by CPU.
We can find memory address by using a format specifier %u
Let us see the code to find the address of a specific variable in C.
#include<stdio.h>
int main()
{
char a;
int x;
float p,q;
a='a';
x=125;
p=10.25,q=18.76;
printf("%c is stored at address %u\n",a,&a);
printf("%d is stored at address %u\n",x,&x);
printf("%f is stored at address %u\n",p,&p);
printf("%f is stored at address %u\n",q,&q);
return 0;
}
In the above program,
Character format specifier is %c
Integer format specifier is %d
or %i
float format specifier is %f
OUTPUT:
a is stored at address 2686751 125 is stored at address 2686744 10.250000 is stored at address 2686740 18.760000 is stored at address 2686736