computer science

profilew.2.a

Grading Information: This Lab Homework is worth 76 points and due by Sunday of week 2 at midnight CST.

The purpose of this assignment is to assess if you can create a program that uses recursion.

DirectionsPoints
The file must be called week2Prog.cpp5
Program Definition
  1. Create program definition for sumDigits Function. Function will receive and return an integer.
6
Main Method
  1. Ask for input for numerous non-negative integers.
  2. Using pass-by-reference, pass integer received into recursive function called sumDigits.
  3. Receive result back from sumDigits and output result to screen.
  4. Include: system("PAUSE"); after your output to pause the screen.
    See example below.
20
sumDigits Function (Receives integer)
  1. Recursively call sumDigits adding up the integers received.
  2. Return result to main method for output.
  3. If a single digit is received, just return it to the main method.
30
Ensure you include ALL .cpp file(s) and any associated, student-defined .h (header) files required to make your program compile and run. The only files in the dropbox should be .cpp and .h files.  Do not turn in .zip, .exe, .rar, etc files.10
Upload your page to the Dropbox.

NOTE: Complete your activity and submit it to the Dropbox by clicking on the Dropbox tab at the top of the course frame and choosing the correct Weekly Activity. 
If needed, click on the Help button above for more information on Course Tools/Using the Dropbox.

5

Total Possible Points

76
Example output of your program

Run 1:
Enter a nonnegative integer: 23
The sum of the digits of 23 is 5

Run 2:
Enter a nonnegative integer: 1234
The sum of the digits of 1234 is 10

Run 3:
Enter a nonnegative integer: 90513
The sum of the digits of 90513 is 18

Run 4:
Enter a nonnegative integer: 2147483647
The sum of the digits of 2147483647 is 46

 

    • 10 years ago
    • 10
    Answer(1)

    Purchase the answer to view it

    blurred-text
    Bids(0)