Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions