1
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
2
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
double foo(double); /* Line 1 */
int main () {
  double da, db;
  //input da
  db = foo(da);
}
double foo(double a){
  return a;
}
The above code compiled without any error or warning. If Line 1 is deleted, the above code will show:
A
no compile warning or error
B
some compiler-warnings not leading to unintended results
C
some compiler-warnings due to type-mismatch eventually leading to unintended results
D
compiler errors
3
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C function:
int f(int n)
{
static int i = 1;
if(n>=5) return n;
n = n+1;
i++;
return f(n);
}
The value returned by f(1) is
A
5
B
6
C
7
D
8
4
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program
main ( )
{
  int x, y, m, n;
  scanf("%d %d", &x, &y);
  /* Assume x > 0 and y > 0 */
  m=x; n=y;
  while(m!=n)
  {
    if(m>n)
    m=m-n;
    else
    n=n-m;
  }
  printf("%d", n);
}
The program computes
A
x + y using repeated subtraction
B
x mod y using repeated subtraction
C
the greatest common divisor of x and y
D
the least common multiple of x and y
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