Why is the address of the array coming out to be the same?

Here is the code. I think it is similar to initializing like another variable, but I can’t justify myself why the address is the same always. It is like the for loop like
for(int i=0;i<n;i++) where i got initialized only one time? Another code (int var)
Thanks.

When same variable is initialized again and again within a loop, its address in the memory remains same. So the same address is reused again and again. Only the content at that address may change.

1 Like

@pratyush63 thanks, maybe it is because that compiler looks up for the variable and if it is already defined earlier, it allocates the same address or reuses it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.