Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started