Saturday, 25 February 2017

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: (B)
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.

No comments:

Post a Comment