Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What must you do if you code an infinite loop in aprogram? - Use a counter variable to determine when the loop ends -

1. What must you do if you code an infinite loop in aprogram?

- Use a counter variable to determine when the loop ends

- Use a Boolean expression to determine when the loop ends

- Code just a single statement within the loop

- Stop the application to end the loop

2. Which of the following statements do you use to jump tothe end of a loop from within the loop?

- continue

- break

- end

- repeat

3. How many lines are printed on the console when thefollowing for loop is executed?
for (int i = 2; i < 10; ++i) {
cout << i << endl;
}

- 8

- 9

- 10

- 7

4. How many lines are printed on the console when thefollowing for loops are executed?
for (int i = 1; i < 5; i += 2) {
for (int j = 0; j < i; ++j) {
cout << j < }
}

- 2

- 4

- 5

- 20

5. Code Example 4-2
int main() {
double subtotal = 0.0;
char choice = 'y';
while (choice == 'y') {
cout << "Entersubtotal: ";
cin >>subtotal;

double sales_tax =subtotal * .0875;
double invoice_total =subtotal + sales_tax;
cout << "Subtotal= " << subtotal << ""
<< " Sales tax = " << sales_tax<< ""
<< "Invoice total = " << invoice_total <<"";

cout << "Continue?(y/n): ";
cin >>choice;
cout < }
}

(Refer to Code Example 4-2.) If the userenters “Y” at the Continue prompt, the application will

- repeat the while loop

- display a blank line, then repeat the while loop

- end

Step by Step Solution

3.32 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Answer and step by step explanation 1 What must you do if you code an infinite loop in a program Use ... 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

Cornerstones of Financial and Managerial Accounting

Authors: Rich, Jeff Jones, Dan Heitger, Maryanne Mowen, Don Hansen

2nd edition

978-0538473484, 538473487, 978-1111879044

More Books

Students also viewed these Programming questions

Question

What is your greatest strength?

Answered: 1 week ago

Question

Case : Karl and June Monroe

Answered: 1 week ago

Question

If 2 5 9 - k 5 8 = 2 5 8 , what is the value of k?

Answered: 1 week ago