Question: C++ Program Write a recursive function that computes the sum of the digits in an integer. Use the following function header int sumDigits(int number) For
Write a recursive function that computes the sum of the digits in an integer. Use the following function header int sumDigits(int number) For example, sumDigits(234) returns the value 9 because 2 +3 +4-9 From main, test the function using a loop that repeatedly prompts the user to enter an integer and displays its sum. Do not allow the user to input negative integers, re-prompt if they do. The last digit (ones place) can be extracted by using the modulus operator. Then, you can remove the last digit by dividing. 54 % 10,4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
