After the execution of first two statements in main()
function, the variables in memory are stored like $\Rightarrow $
Now address of $a$ is passed to function foo()
where there is a local variable $a$ that stores the address of pointer passed. (Lets say this local variable as $a'$ )
So, when foo()
executes its first two statements memory layout is like ::
So, printf()
inside foo()
prints $\color{blue}{210}$.
After foo()
completes its activation record is removed from stack. So, only variable $i$ and pointer $a$ remain in memory, where $a$ points to an address that is not available now.
Now what last two printfs will print depends on how compiler behaves when it removes activation record. If it replaces memory location $400$ (variable j) with $0$, it will print $0$ or if it retains previous value that is $210$, it will print $210$.