The GATE Grind

GATE 2026 CS (CS2) – Question 17

Programming and Data Structures · Programming in C · 1 mark · Multiple choice

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

  1. A static variable declared inside a function
  2. An array of integers declared inside a function
  3. A dynamically allocated array of integers created using `malloc()`
  4. Return address of a function

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) A dynamically allocated array of integers created using `malloc()`

Explanation

Memory obtained through `malloc()` is allocated from the heap. In contrast, static variables are stored in the data segment, local arrays are usually stored on the stack, and return addresses are also stored on the stack. Therefore, option (C) is correct.