1
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 2
GATE CSE 2011
+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)?
A
345
B
12
C
5
D
3
3
GATE CSE 2011
+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)?
A
9
B
8
C
5
D
2
4
GATE CSE 2008
+2
-0.6
Choose the correct option to fill ? 1 and ? 2 so that the program below prints an input string in reverse order. Assume that the input string is terminated by a newline character.
void recerse (void) {
int c;
if (?1) reverse() ;
?2
}
main {
printf ("Enter Text" );
printf("\n");
reverse() ;
printf("\n") ;
}
A
?1 is (getchar ( )! = '\ n')
?2 is getchar (c);
B
?1 is ((c = getchar ( ) )! = '\ n')
?2 is getchar (c);
C
?1 is (c ! = '\ n')
?2 is putchar (c);
D
?1 is ((c = getchar ( ) )! = '\ n')
?2 is putchar (c);
GATE CSE Subjects
Discrete Mathematics
Programming Languages
Theory of Computation
Operating Systems
Digital Logic
Computer Organization
Database Management System
Data Structures
Computer Networks
Algorithms
Compiler Design
Software Engineering
Web Technologies
General Aptitude
EXAM MAP
Joint Entrance Examination