Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

EX 4

// Program SumDigits prompts for and reads a one-digit number. // Values between 0 and the digit (inclusive) are summed.

#include using namespace std;

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

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

What is job rotation ?

Answered: 1 week ago