Skip to content
Official PYQ · 2026

GATE CS 2026 Set 2 Q7 — Programming in C

Explain with AI

In C runtime environment, which one of the following is stored in heap?

Choose one option
View worked solution

Answer: C

The correct option is C.

In the C runtime memory layout, the memory is divided into several segments: Code (Text), Data (Initialized/BSS), Stack, and Heap. Let's analyze where each option is stored:

  • Option A: A static variable declared inside a function has a lifetime that spans the entire execution of the program. It is stored in the Data Segment (either initialized data segment or BSS depending on whether it is initialized or not).
  • Option B: An array of integers declared inside a function (without the static keyword) is a local (automatic) variable. It is stored on the Stack within the function's activation record.
  • Option C: Memory allocated dynamically at runtime using functions like malloc(), calloc(), or realloc() is allocated from the Heap.
  • Option D: The return address of a function is part of the function's activation record (stack frame) and is stored on the Stack to resume execution after the function call completes.

Therefore, only the dynamically allocated array of integers (Option C) is stored in the heap.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Programming in C questions