Vidyalelo
Data Structure · Q617

Miscellaneous on Data Structures

Programming · Data Structure · question 617

Q617

Consider the following recursive implementation to find the sum of digits of number: #include int recursive_sum_of_digits(int n) if(n == 0) return 0; return _________; int main() int n = 1201; int ans = recursive_sum_of_digits(n); printf("%d",ans); return 0; Which of the following lines should be inserted to complete the above code?

A.
(n / 10) + recursive_sum_of_digits(n % 10)
B.
(n) + recursive_sum_of_digits(n % 10)
C.
(n % 10) + recursive_sum_of_digits(n / 10)
Answer
D.
(n % 10) + recursive_sum_of_digits(n % 10)

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board