Gate CS-2011 Question Paper With Solutions

Q. 49 Consider the following recursive C function that takes two arguments.

unsigned int foo(unsigned int n, unsigned int r) {
    if (n>) return ((n%r) + foo(n/r, r));
    else return ;
}

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

Answer: (D)

Explanation:

Gate CS-2011 Question Paper With Solutions

Learn More:   Gate EC-2006 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here