Question: In C++ please: 11.16 LAB: sumOfDigits Write the recursive function int sumOfDigits(int n) that returns the sum of the digits of n recursively. For example,

In C++ please: 11.16 LAB: sumOfDigits

Write the recursive function int sumOfDigits(int n) that returns the sum of the digits of n recursively. For example, sumOfDigits(392) should return 14 because 3 + 9 + 2 = 14. Hint: use arithmetic operators to separate the digits of n.

Write function main to read in a single integer and to output the return value of sumOfDigits called on this value. You must call the recursive function sumOfDigits described above to receive credit.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!