M02 Flashcards
A control structure alters the normal sequential flow of execution in a program.
True
The result of a logial expression cannot be assigned to an int variable, but it can be assigned to a bool variable.
False
In C++, both ! and != are relational operatios.
False
The expression (x >= 0 && x = 100).
False
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 l l .
True
The operator != and == have the same order of precedence.
True
A compound statement functions as if it was a single statement.
True
if the expression is an assert statement evaluates to true, the program terminates.
False
In a __ control structure, the computer executes particular statements depending on some condition(s).
selection
What does
less than or equal to
Which of the following is a relational operator?
a. =
b. ==
c. !
d.
b. ==
Which of the follwing is the “not equal to” relational operator?
a. !
b. l
c. !=
d.
c. !=
Suppose x is 5 and y is 7. Choose the value of the following expression:
(x != 7) && (x
true
Suppose that x is an int variable. Which of the following expressions always evaluates to true?
a. (x > 0) || ( x = 0) || (x == 0)
c. (x > 0) && ( x 0) && (x == 0)
a. (x > 0) || ( x
Which of the following expressions correctly determines that x is greater than 10 and less than 20?
a. 10
c. 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
35 45 10
What is the output of the following code?
if (6 > 8)
{
cout
*
Which of the following will cause a logical error if you are attempting to compare x to 5?
a. if (x = 5)
c. if (x == 5)
d. if (x = 5)
d. if (x = 5)
What is the output of the following code?
char lastInitial = ‘S’;
switch (lastInitial)
{
case ‘A’:
cout
section 5
char lastInitial = ‘A’;
switch (lastInitial)
{
case ‘A’:
cout
section 1
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
2
You can disable assert statements by using which of the following?
a. #include
b. #define
c. #clear NDEBUG
d. #define NDEBUG
d. #define NDEBUG
The __ holds the insturctions currently being executed.
IR