Q46: Where is this variable stored?

Based on the following memory layout, answer the following question.

memory layout

Consider the following C program:

#include <stdio.h>

int iglobal = 10;

int uglobal;

&nbsp;

int main(void)

{

static int i;

int j;

return 0;

}

Question #46: Where does the variable ‘j’ go?

Options:

  1. heap
  2. Uninitialized data (bss)
  3. Stack
  4. Initialized data

Solution: ‘j’ is a local variable, all local variables go to stack. Hence, the correct answer is option 3. Checkout a similar question here.