1
GATE CSE 2014 Set 2
+2
-0.6
Consider the C function given below.
int f(int j)
{
static int i = 50;
int k;
if (i == j)
{
printf("something");
k = f(i);
return 0;
}
else return 0;
}
Which one of the following is TRUE?
A
The function returns 0 for all values of j.
B
The function prints the string something for all values of j.
C
The function returns 0 when j = 50.
D
The function will exhaust the runtime stack or run into an infinite loop when j = 50.
2
GATE CSE 2014 Set 2
Numerical
+2
-0
Consider the following function
double f (double x) {
if ( abs (x * x – 3) < 0. 01) return x;
else return f (x / 2 + 1.5/x);
}
Give a value q (to 2 decimals) such that f(q) will return q:______.
3
GATE CSE 2013
+2
-0.6
What is the return value of f (p, p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value.
int f (int &x, int c) {
c = c - 1;
if (c==0) return 1;
x = x + 1;
return f(x,c) * x;
}
A
3024
B
6561
C
55440
D
161051
4
GATE CSE 2008
+2
-0.6
Which of the following are true?

I. A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation

II. Multi-level access link (or display) arrangement is needed to arrange activation records only if the programming language being implemented has nesting of procedures/functions

III. Recursion in programming languages cannot be implemented with dynamic storage allocation

IV. Nesting procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stack-based allocation scheme for activation records

V. Programming languages which permit a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records

A
II and V only
B
I, III and IV only
C
I, II and V only
D
II, III and V only
GATE CSE Subjects
EXAM MAP
Medical
NEET