Question: When I was trying to print the address of the first variable in main function, I found that the result is always same after running few times. Why? Is it in the virtual memory or physical memory?

```c
#include <stdio.h>

int main()
{
    int a;

    printf("a's address is %p\n", &a);

    return 0;
}

```

I expect the output will be different every time, but the actual output is always 0028FF3C

Answer: 
On some systems, [ASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization) is enabled, and for good reasons.

For example, on my Linux/Debian/Sid x86-64 your program gives each time different addresses:

```
repeat 10 tmp/sange
a's address is 0x7fff2768303c
a's address is 0x7ffc5d26a57c
a's address is 0x7ffcc0a4b2ac
a's address is 0x7ffeec95fd7c
a's address is 0x7ffefd5318dc
a's address is 0x7ffc544497bc
a's address is 0x7fff232f7dac
a's address is 0x7fff9dd3b65c
a's address is 0x7fff9e6858dc
a's address is 0x7ffc2876d4bc

```

To learn more, read about [undefined behavior](https://en.wikipedia.org/wiki/Undefined_behavior) (e.g. [Lattner's blog](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html)), [unspecified behavior](https://en.wikipedia.org/wiki/Unspecified_behavior), and read a good textbook about operating systems, e.g. [*Operating Systems: Three Easy Pieces*](http://pages.cs.wisc.edu/~remzi/OSTEP/) (freely downloadable)

Read also about [virtual address space](https://en.wikipedia.org/wiki/Virtual_address_space).
**No** the address is not fixed.
--------------------------------

It is up to your OS to decide where the program is loaded and consequently to which address the variable is assigned.

If the address is physical of virtual, it depends on your OS as well. It decides how to manage memory.