Following questions have been asked in GATE CS exam.
1. In the C language (GATE CS 2002)
a) At most one activation record exists between the current activation record and the activation record for the main
b) The number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence.
c) The visibility of global variables depends on the actual function calling sequence.
d) Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive function can be called.
a) –> There is no such restriction in C language
b) –> True
c) –> False. In C, variables are statically scoped, not dynamically.
c) –> False. The activation records are stored on the same stack.
2. Consider the C program shown below.
# include <stdio.h>
# define print(x) printf ("%d", x)
z += x;
x = *y+2;
*y = x-1;
The output of this program is (GATE CS 2003)
b) 22 12 11
c) 14 6 6
Note that main() and Q() are accessing the global variable x. Inside P(), pointer variable y also holds address of global variable x, but x in P() is its P’s own local variable.
Please see GATE Corner for all previous year paper/solutions/explanations, syllabus, important dates, notes, etc.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
Level Up Your GATE Prep!
Embark on a transformative journey towards GATE success by choosing Data Science & AI
as your second paper choice with our specialized course. If you find yourself lost in the vast landscape of the GATE syllabus, our program is the compass you need.