1
GATE CSE 2015 Set 2
Numerical
+2
-0
Consider the C program below.
#include < stdio.h >
int *A, stkTop;
int stkFunc(int opcode, int val)
{
static int size=0, stkTop=0;
switch (opcode) {
case -1: size = val; break;
case 0: if (stkTop < size) A[stkTop++] = val; break;
default: if (stkTop) return A[--stkTop];
}
return -1;
}
int main()
{
int B[20]; A = B; stkTop = -1;
stkFunc (-1, 10);
stkFunc ( 0, 5);
stkFunc ( 0, 10);
printf ("%d\n", stkFunc(1, 0) + stkFunc(1, 0));
}
The value printed by the above program is __________.Your input ____
2
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
Consider the program given below, in a block-structured pseudo-language with lexical
scoping and nesting of procedures permitted.
The correct set of activation records along with their access links is given by
Program main;
Var . . .
Procedure A1;
Var . . .
Call A2;
End A1
Procedure A2;
Var . . .
Procedure A21;
Var . . .
Call A1;
End A21
Call A21;
End A2
Call A1;
End main.
Consider the calling chain: Main $$ \to $$ A1 $$ \to $$ A2 $$ \to $$ A21 $$ \to $$ A1
The correct set of activation records along with their access links is given by
3
GATE CSE 2011
MCQ (Single Correct Answer)
+2
-0.6
Consider the following recursive C function that takes two arguments:
unsigned int foo (unsigned int n, unsigned int r) {
if (n > 0) return((n % r) + foo(n/r, r));
else return 0;
}
What is the return value of the function foo when it is called as foo (345, 10)?4
GATE CSE 2011
MCQ (Single Correct Answer)
+2
-0.6
Consider the following recursive C function that takes two arguments:
unsigned int foo (unsigned int n, unsigned int r) {
if (n > 0) return((n % r) + foo(n/r, r));
else return 0;
}
What is the return value of the function foo when it is called as foo (513, 2)? Questions Asked from Function and Recursion (Marks 2)
Number in Brackets after Paper Indicates No. of Questions
GATE CSE 2024 Set 1 (1)
GATE CSE 2022 (1)
GATE CSE 2021 Set 2 (1)
GATE CSE 2021 Set 1 (2)
GATE CSE 2020 (2)
GATE CSE 2018 (1)
GATE CSE 2015 Set 2 (1)
GATE CSE 2012 (1)
GATE CSE 2011 (2)
GATE CSE 2008 (1)
GATE CSE 2007 (1)
GATE CSE 2005 (2)
GATE CSE 2004 (2)
GATE CSE 2003 (1)
GATE CSE 2002 (1)
GATE CSE 2000 (1)
GATE CSE 1999 (1)
GATE CSE 1998 (2)
GATE CSE 1995 (1)
GATE CSE 1993 (1)
GATE CSE Subjects
Theory of Computation
Operating Systems
Algorithms
Database Management System
Data Structures
Computer Networks
Software Engineering
Compiler Design
Web Technologies
General Aptitude
Discrete Mathematics
Programming Languages