A language L allows declaration of arrays whose sizes are not known during…

1997

A language L allows declaration of arrays whose sizes are not known during compilation. It is required to make efficient use of memory. Which of the following is true?

  1. A.

    A compiler using static memory allocation can be written for L

  2. B.

    A compiler cannot be written for L, an interpreter must be used

  3. C.

    A compiler using dynamic memory allocation can be written for L

  4. D.

    None of the above

Attempted by 30 students.

Show answer & explanation

Correct answer: C

  • The Problem: The size of the arrays is unknown at compile time.

  • The Constraint: Static allocation requires all memory sizes to be fixed and known before the program runs, so it cannot handle variable-sized arrays efficiently.

  • The Solution: A compiler can easily handle this by generating code that allocates memory at runtime (when the size becomes known) using dynamic memory allocation (via heap). This allows the program to allocate exactly the amount of memory needed, satisfying the efficiency requirement

Explore the full course: Gate Guidance By Sanchit Sir