Computer Programming C++ Chapter Four

¡Supera tus tareas y exámenes ahora con Quizwiz!

The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.

False

What is the output of the following loop? count = 5; cout << 'St'; do { cout << 'o'; count--; } while (count <= 5);

This is an infinite loop.

Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y)

True

The expression in an if statement is sometimes called a(n) ____.

decision maker

____ loops are called posttest loops.

do...while

Which of the following loops is guaranteed to execute at least once?

do...while loop

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

looping

When one control statement is located within another, it is said to be

nested

Consider the following statements. int score; string grade; if (score >= 65) grade = "pass"; else grade = "fail"; If score is equal to 75, the value of grade is "____________________".

pass

What is the value of x after the following statements execute? int x; x = (5 <= 3 && 'A' < 'F') ? 3 : 4

4

What is the value of x after the following statements execute? int x = 5; int y = 30; do x = x * 2; while (x < y);

40

Suppose that x is an int variable. Which of the following expressions always evaluates to true?

(x > 0) || ( x <= 0)

What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl;

10

Which of the following expressions correctly determines that x is greater than 10 and less than 20?

10 < x && x < 20

Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code? sum = 0; cin >> num; while (num != -1) { sum = sum + num; cin >> num; } cout << sum << endl;

110

Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code? sum = 0; cin >> num; for (int j = 1; j <= 4; j++) { sum = sum + num; cin >> num; } cout << sum << endl;

125

What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; } cout << y << endl;

2

What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { num = num - 1; count++; } cout << count << " " << num << endl;

25 1

Which of the following will cause a logical error if you are attempting to compare x to 5?

if (x = 5)

A loop that continues to execute endlessly is called a(n) ____ loop.

infinite


Conjuntos de estudio relacionados

Chp. 32: Fetal Environment and Maternal Complications

View Set

Adult Health 2 Final Exam Review

View Set

Life Insurance Licensing Chapter 3

View Set

ACT study guide Math: Linear Inequalities with One Variable

View Set

Service Response Logistics (Chapter 12)

View Set