GATE | GATE CS 2011 | Question 48
Consider the following recursive C function that takes two arguments
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
What is the return value of the function foo when it is called as foo(345, 10) ?
Explanation: The call foo(345, 10) returns sum of decimal digits (because r is 10) in the number n. Sum of digits for 345 is 3 + 4 + 5 = 12.
This solution is contributed by Pranjul Ahuja
Quiz of this Question