Question: 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++

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

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

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!