GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 1.17

Activation records and actual calls

Programming in C · Functions & Parameter Passing · Full GATE CSE 2002 paper

GATE 2002, Q1.17 1 mark · MCQ
Report issue

Functions & Parameter Passing

Question 1.17, GATE 2002: Select the correct statement about C.
(A) At most one activation record lies between the current record and main’s record.
(B) The number of activation records between the current record and main’s record depends on the actual sequence of function calls.
(C) Visibility of global variables depends on the actual sequence of function calls.
(D) Before a recursive call, the recursive function’s activation record must be saved on another stack.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Trace a concrete call chain.

Step 2: If main calls f and f calls g, the active stack contains main,f,g. If g recursively calls itself, another g activation is needed while the earlier one remains active. Thus the number of intervening records changes with actual calls. Lexical visibility is determined by declarations and scopes, not by this stack depth.

Conclusion: The runtime activation chain follows the actual sequence of function calls. Its depth between the current function and main therefore depends on that sequence, B. C uses lexical rather than dynamic scope for global names, and recursive calls can use successive records on the same runtime stack.

Original paper, page 2