True |
A control structure alters the normal sequential flow of execution in a program. |
False |
The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable. |
False |
In C++, both ! and != are relational operators. |
False |
In C++, !, &&, and || are called relational operators. |
False |
The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100. |
True |
Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true. |
True |
In C++, && has a higher precedence than ||. |
True |
The operators != and == have the same order of precedence. |
True |
A compound statement functions as if it was a single statement. |
False |
If the expression in an assert statement evaluates to true, the program terminates. |
selection |
In a ____ control structure, the computer executes particular statements depending on some condition(s). |
less than or equal to |
What does <= mean? |
== |
Which of the following is a relational operator? |
!= |
Which of the following is the "not equal to" relational operator? |
true |
Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y) |
(x > 0) || ( x <= 0) |
Suppose that x is an int variable. Which of the following expressions always evaluates to true? |
! |
Which of the following operators has the highest precedence? |
= |
Which of the following operators has the lowest precedence? |
10 < x && x < 20 |
Which of the following expressions correctly determines that x is greater than 10 and less than 20? |
decision maker |
The expression in an if statement is sometimes called a(n) ____. |
35 45 10 |
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; |
nested |
When one control statement is located within another, it is said to be ____. |
* |
What is the output of the following code? if (6 > 8) { cout << " ** " << endl ; cout << "****" << endl; } else if (9 == 4) cout << "***" << endl; else cout << "*" << endl; |
if (x = 5) |
Which of the following will cause a logical error if you are attempting to compare x to 5? |
silent killer |
The appearance of = in place of == resembles a(n) ____. |
2 |
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;. |
three |
The conditional operator ?: takes ____ arguments. |
4 |
What is the value of x after the following statements execute? int x; x = (5 <= 3 && ‘A’ < ‘F’) ? 3 : 4 |
pseudocode |
To develop a program, you can use an informal mixture of C++ and ordinary language, called ____. |
section 5 |
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 1 |
What is the output of the following code? char lastInitial = ‘A’; 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; } |
13 |
What is the output of the following code fragment if the input value is 4? int num; int alpha = 10; cin >> num; switch (num) { case 3: alpha++; break; case 4: case 6: alpha = alpha + 3; case 8: alpha = alpha + 4; break; default: alpha = alpha + 5; } cout << alpha << endl; |
2 |
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; |
#include <cassert> |
For a program to use the assert function, it must include which of the following? |
#define NDEBUG |
You can disable assert statements by using which of the following? |
&& |
In C++, the logical operator AND is represented by ____________________. |
true |
The value of the expression 7 + 8 <= 15 is ____________________. |
relational |
The symbol > is a(n) ____________________ operator. |
relational |
A ____________________ operator allows you to make comparisions in a program. |
! |
Putting ____________________ in front of a logical expression reverses the value of that logical expression. |
false |
The value of the expression 6 < 5 || ‘g’ > ‘a’ && 7 < 4 is ____________________. |
false |
Suppose found = true and num = 6. The value of the expression (!found) || (num > 6) is ____________________. |
associativity |
The ____________________ of relational and logical operators is said to be from left to right. |
semantic |
Putting a semicolon after the parentheses following the expression in an if statement (that is, before the statement) is a(n) ____________________ error. |
pass |
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 "____________________". |
if |
Every else must be paired with a(n) ____________________. |
short circuit evaluation |
The term ____________________ describes a process in which the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known. |
fail |
Once an input stream enters a(n) ____________________ state, all subsequent input statements associated with that input stream are ignored, and the computer continues to execute the program, which produces erroneous results. |
switch |
A(n) ____________________ structure does not require the evaluation of a logical expression. |
break |
To output results correctly, the switch structure must include a(n) ____________________ statement after each cout statement, except the last cout statement. |
CS 150 Chapter 4
Share This
Unfinished tasks keep piling up?
Let us complete them for you. Quickly and professionally.
Check Price