Consider the following recursive C function that takes two arguments. unsigned…

PYQ GATE 2011

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)?

  1. A.

    345

  2. B.

    12

  3. C.

    5

  4. D.

    3

Attempted by 413 students.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…