1
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
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 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);
4
GATE CSE 2007
+2
-0.6
Consider the following C function:
int f(int n)
{
static int r = 0;
if(n <= 0) return 1;
if(n>3)
{
r = n;
return f(n-2)+2;
}
return f(n-1)+r;
}
What is the value of f(5)?
A
5
B
7
C
9
D
18
GATE CSE Subjects
EXAM MAP
Medical
NEET
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
CBSE
Class 12