C | Dynamic Memory Allocation | Question 8

Last Updated :
Discuss
Comments
Consider the following program, where are i, j and k are stored in memory? C
int i;
int main()
{
    int j;
    int *k = (int *) malloc (sizeof(int));
}
i, j and *k are stored in stack segment
i and j are stored in stack segment. *k is stored on heap.
i is stored in BSS part of data segment, j is stored in stack segment. *k is stored on heap.
j is stored in BSS part of data segment, i is stored in stack segment. *k is stored on heap.
Tags:
Share your thoughts in the comments