Chapter 4

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following is the "not equal to" relational operator?

!=

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? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y - x; cout << x << " " << y << " " << z << endl;

35 45 10

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

4

Which of the following operators has the lowest precedence?

=

Which of the following is a relational operator?

==

If the expression in an assert statement evaluates to true, the program terminates.

False

In C++, both ! and != are relational operators.

False

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

False

The operators !, &&, and || are called relational operators.

False

The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.

False

A compound statement functions as if it was a single statement.

True

A control structure alters the normal sequential flow of execution in a program.

True

In C++, && has a higher precedence than ||.

True

In C++, the operators != and == have the same order of precedence.

True

Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.

True

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

True

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

if (x = 5)

You can use either a(n) ____ or a ____ to store the value of a logical expression.

int, bool

What does <= mean?

less than or equal to

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

nested

For a program to use the assert function, it must include which of the following?

#include <cassert>

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

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

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

10 < x && x < 20

Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the following expression: z = (y / x > 0) ? x : y;

2

What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl; }

section 5

In a ____ control structure, the computer executes particular statements depending on some condition(s).

selection

You can disable assert statements by using which of the following?

#define NDEBUG


Kaugnay na mga set ng pag-aaral

Reflections of Exponential Functions Assignment

View Set

7 Human Population Change and the Environment Ch. 7

View Set

the hypothalamus and pituitary gland

View Set

Sports and Play Chapter 6: Violence in Sports

View Set

Chapter 12: Nursing Management During Pregnancy (PrepU)

View Set

Chapter 19 Marketing, Chapter 18 Advertising, Public Relations, and Sales Promotions, Chapter 18, Marketing Ch. 18

View Set