Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Get the sum of the numbers using a recursive function. C++ 1. Write the recursive function sumDigits, which accepts a single long as input and
Get the sum of the numbers using a recursive function. C++
1. Write the recursive function sumDigits, which accepts a single long as input and returns an int which contains the sum of all the digits in the number. For example: sumDigits(num) num 12345 100000009 10 15 2. Write 3 additional test cases, similar to the ones in the main function, to test the function sumDigits. You should test different things than what is already there. Your tests must compile and your function sumDigits should also pas them 3. Write the recursive function sumEveryOtherDigit, which accepts a single long as input and returns an int which contains the sum of every other digit in the number. For example, given the number 12345, it returns 9, which is surm of 5 3 + 1. The summing always starts on the right, just like with the previous function. sumEveryOtherDigit(num) num 12345 2000000345 8 4. Write 3 additional test cases, similar to the ones in the main function, to test the function sumEveryOtherDigit. You should test different things than what is already there. Your tests must compile and your function sumEveryOtherDigit should also pass them 5. Document your program by writing comments for the program as a whole and for each function. Be sure to document the parameters and return value
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