GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Does declaration of variable allocates memory in C?

In C, Whether memory will be allocated when the variable is declared? For ex, does statement int a; allocates memory for a?

asked Nov 13, 2015 by ArvindGilkinja

2 Answers

Best answer

Yes, when you declare a variable like int a;

Memory is allocated it can seen by running the code

using namespace std;
int main()
    int a;
    return 0;

This prints the address of the variable.What does that mean?. It means that variable exist in memory.

link to code is:

answered Nov 13, 2015 by passion34
selected Nov 13, 2015 by ArvindGilkinja