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
Get step-by-step solutions from verified subject matter experts
