1
GATE CSE 2020
Numerical
+2
-0.67
Consider the following C functions.
int fun1 (int n) {
static int i = 0;
if (n > 0) {
++i;
fun1(n-1);
}
return (i);
}

___________________
int fun2 (int n) {
static int i = 0;
if (n > 0) {
i = i + fun1 (n);
fun2(n-1);
}
return (i);
}

The return value of fun2 (5) is _______.
2
GATE CSE 2018
+2
-0.6
Consider the following C code. Assume that unsigned long int type length is 64 bits.
unsigned long int fun(unsigned long int n){
unsigned long int i, j = 0, sum = 0;
for (i = n; i > 1; i = i/2) j++;
for ( ; j > 1; j = j/2) sum++;
return(sum);
}
The value returned when we call fun with the input $${2^{40}}$$ is
A
4
B
5
C
6
D
40
3
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 __________.
4
GATE CSE 2012
+2
-0.6
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
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
A
B
C
D
GATE CSE Subjects
EXAM MAP
Medical
NEET