Sail E0 Webinar
Question
Consider the following recursive implementation to find the sum of digits of number:#includeint 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?
Options:
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)
D .  (n % 10) + recursive_sum_of_digits(n % 10)
Answer: Option C


The line "(n % 10) + recursive_sum_of_digits(n / 10) should be inserted to complete the above code.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers