Correct : c
The correct answer is Option C — A dynamically allocated array of integers created using malloc().
The C runtime memory layout is divided into distinct regions. The stack holds local variables, function parameters, and return addresses — all with automatic lifetime tied to their scope. The BSS/data segment holds global and static variables. The heap is the region explicitly managed by the programmer for dynamic memory allocation.
Option A — Static variable inside a function: The static keyword gives a variable static storage duration regardless of where it is declared. It is stored in the BSS or data segment, persisting for the entire program lifetime. Not heap.
Option B — Array declared inside a function: A locally declared array like int arr[10] inside a function is a local variable with automatic storage duration — it lives on the stack and is destroyed when the function returns. Not heap.
Option C — Dynamically allocated array via malloc(): malloc() explicitly requests memory from the heap at runtime. The programmer is responsible for freeing it using free(). This is the canonical use of heap memory. Heap ✓ Correct.
Option D — Return address of a function: When a function is called, the CPU pushes the return address onto the call stack so execution can resume at the correct point after the function completes. Not heap.
Similar Questions
Total Unique Visitors