GATE CS 2011 · Question 48 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer
Common Data for Questions 48 and 49: 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
Answer
Answer (B)
Answer from the official GATE CS 2011 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes