NEW
New Website Launch
Experience the best way to solve previous year questions with mock tests (very detailed analysis), bookmark your favourite questions, practice etc...
1

### GATE CSE 2005

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 2004

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
3

### GATE CSE 2004

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 2003

Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.
Class P {
void f(int i) {
print(i);
}
}

Class Q subclass of P {
void f(int i) {
print(2*i);
}
}
Now consider the following program fragment:
Px = new Q();
Qy = new Q();
Pz = new Q();
x.f(1); ((P)y).f(1); z.f(1);
Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be
A
1 2 1
B
2 1 1
C
2 1 2
D
2 2 2
Write for Us

Do you want to write for us? Help us by contributing to our platform.

### Joint Entrance Examination

JEE Main JEE Advanced WB JEE

### Graduate Aptitude Test in Engineering

GATE CSE GATE ECE GATE EE GATE ME GATE CE GATE PI GATE IN

NEET

Class 12