Question 18 (4 points) Question 18 Unsaved In the code shown below, the computer
ID: 3807465 • Letter: Q
Question
Question 18 (4 points) Question 18 Unsaved
In the code shown below, the computer continues processing the inner loop’s instructions until the user enters __________, at which time the inner loop ends.
int sales = 0;
int region = 1;
int totRegSales = 0;
while (region < 3)
{
cout << "First sales amount for Region "
<< region << ": ";
cin >> sales;
while (sales > 0)
{
totRegSales = totRegSales + sales;
cout << "Next sales amount for Region "
<< region << ": ";
cin >> sales;
} //end while
cout << endl << "Region " << region << " sales: $"
<< totRegSales << endl << endl;
region = region + 1;
totRegSales = 0;
} //end while
cout << "End of program" << endl;
Question 18 options:
a. a negative number
b. either the number 0 or a negative number
c. a number greater or equal than 3
d. the number 0
Explanation / Answer
Answer b. Either the number 0 or a negative number.
Explanation: Inner loop is while(sales>0) therefore the inner loop executes until the user enters 0 or negative number
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.