Question
c++ EX 4 // Program SumDigits prompts for and reads a one-digit number. // Values between 0 and the digit (inclusive) are summed. #include using
c++
EX 4
// Program SumDigits prompts for and reads a one-digit number. // Values between 0 and the digit (inclusive) are summed.
#include
int main() { int counter; // Loop-control variable int sum; // Running sum int digit;
cout > digit; counter = 0; sum = 0;
while (counter Exercise: Rewrite your solution to until a negative digit is read. That is, embed your solution within another loop that continues to prompt for a digit and calculates the sum of the digits from zero through digit as long as digit is positive. The process stops when digit is negative. Be sure to add this information to the prompt. Rewrite the program documentation at the beginning of the program to reflect this change. Run your program once using the same data you used in Exercise 4 , Exercise 4, so that the processing is repeated What additional documentation did you include? Is the outer loop a count-controlled loop or an event-controlled loop
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