Consider the following program, where are i, j and k are stored in memory?
#include
#include
int i;
int main()
{
int j;
int *k = (int *) malloc (sizeof(int));
}
Answer: C
i is global variable and it is uninitialized so it is stored on BSS part of Data Segment, j is local in main() so it is stored in stack frame, *k is dynamically allocated so it is stored on Heap Segment.