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

2026

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

  1. A.

    A static variable declared inside a function

  2. B.

    An array of integers declared inside a function

  3. C.

    A dynamically allocated array of integers created using malloc() function call

  4. D.

    Return address of a function

Attempted by 206 students.

Show answer & explanation

Correct answer: C

The correct answer is CA dynamically allocated array of integers created using malloc() function call.

In C runtime memory organization:

  • Heap → stores dynamically allocated memory using malloc(), calloc(), realloc()

  • Stack → stores local variables, function parameters, return addresses

  • Data segment → stores static and global variables

So:

  • A → Static variable → Data segment

  • B → Local array inside function → Stack

  • Cmalloc() allocated array → Heap ✅

  • D → Return address → Stack

Explore the full course: Gate Guidance By Sanchit Sir