1
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)?
A
345
B
12
C
5
D
3
2
GATE CSE 2008
MCQ (Single Correct Answer)
+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);
3
GATE CSE 2007
MCQ (Single Correct Answer)
+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
4
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
void foo (int n, int sum) {
  int k = 0, j = 0;
  if(n==0) return;
  k=n%10; j = n /10;
  sum = sum + k;
  foo(j, sum);
  printf("%d",k);
}
int main () {
  int a = 2048, sum = 0;
  foo(a, sum);
  printf("%d\n", sum);
}
What does the above program print?
A
8, 4, 0, 2, 14
B
8, 4, 0, 2, 0
C
2, 0, 4, 8, 14
D
2, 0, 4, 8, 0
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12