True/False Indicate whether the
statement is true or false.
|
|
|
1.
|
Extended if statements are better to implement than sequential if statements
because they more accurately represent mutually exclusive conditions.
|
|
|
2.
|
Proper usage of switch statements occur when several options depend on the value
of a single variable or expression.
|
|
|
3.
|
A statement block is not allowed in a switch statement.
|
|
|
4.
|
A compound statement in an if...else statement cannot be followed by a
semicolon before the else reserved word.
|
|
|
5.
|
The assert function can be used for debugging a program.
|
|
|
6.
|
Assume Boolean values have been assigned to A, B, and C as A = true;
B = false; C = true; (A && B) ||
(A && C)
|
|
|
7.
|
Assume Boolean values have been assigned to A, B, and C as A = true;
B = false; C = true; (A || ! B)
&& (! A || C)
|
|
|
8.
|
Assume Boolean values have been assigned to A, B, and C as A = true;
B = false; C = true; A || B
&& C
|
|
|
9.
|
Assume Boolean values have been assigned to A, B, and C as A = true;
B = false; C = true; ! A || B
&& C
|
|
|
10.
|
Assume Boolean values have been assigned to A, B, and C as A = true;
B = false; C = true; ! (A || B)
&& C
|
|
|
11.
|
Boolean variables as defined in the text can have values of YES or NO.
|
|
|
12.
|
In an if…else statement, if the conditional is false, the statement
following else is executed.
|
|
|
13.
|
The keyword else is always used with all if statements.
|
|
|
14.
|
Boolean variables can be used in switch statements.
|
|
|
15.
|
Real variables can be used in switch statements.
|
Multiple Choice Identify the
choice that best completes the statement or answers the question.
|
|
|
16.
|
Which is not a C++ data type?
a. | double | c. | int | b. | constant | d. | char |
|
|
|
17.
|
Integer overflow means ____.
a. | too many digits have been entered in a field | b. | the absolute value
of an integer has exceeded a maximum | c. | the absolute value of an integer has not
exceeded a maximum | d. | an integer's value is too large to be
stored in memory |
|
|
|
18.
|
Real overflow occurs ____.
a. | when the blue screen appears halting the windows program | b. | when the absolute
value of an integer exceeds a maximum | c. | when a calculated value is too small to be
stored in memory | d. | when a value is calculated but is too large to be stored in
memory |
|
|
|
19.
|
Which is not a selection method in C++?
a. | one-way | d. | multiway | b. | multiple | e. | three-way | c. | two-way |
|
|
|
20.
|
Which is not a relational operator?
|
|
|
21.
|
Which is not acceptable as a boolean operator?
|
|
|
22.
|
What is a definition of a selection statement?
a. | Nested If...else statements. | b. | Do...While loop. | c. | Block statement with
several if...else statements. | d. | Program statement that transfers control to
various branches of the program. |
|
|
|
23.
|
Which is an example of a control structure?
a. | Parameter list. | c. | Selection statement. | b. | Function declaration. | d. | Simple typedef
declaration. |
|
|
|
24.
|
Which character represents negation in a boolean expression?
|
|
|
25.
|
Which of the following values can be assigned to a Boolean variable?
|
|
|
26.
|
If E1 is true, and E2 is false, then which of the following Boolean expressions
is true?
a. | E1 && E2 | c. | ! (E1 ||
E2) | b. | E1 || E2 | d. | ! (E1) && E2 |
|
|
|
27.
|
Which of the following is NOT a valid comparison operator for use in if
statements?
|
|
|
28.
|
Given the statement: if (A
> 70) || (A < 110) .... which value of A would make this
statement true?
a. | 60 | c. | 130 | b. | 75 | d. | All of these. |
|
|
|
29.
|
The Falcon Necktie Company charges its customers $4.95 per tie if they purchase
up to 5 ties, $4.25 per tie if they purchase 6 to 10 ties, and $3.65 per tie if they purchase more
than 10 ties. The best set of test data to use in evaluating a program designed to process customer
orders given the number of ties purchased is:
a. | 1, 3, 6, 9 | c. | 5, 10,
11 | b. | 1, 2, 3, 6, 7, 8, 11 | d. | 1, 5,
10 |
|
Completion Complete each
statement.
|
|
|
30.
|
Block variables in a(n) ____________________ statement are like
____________________ variables in a function.
|
|
|
31.
|
Selection statements can be used to guard against unexpected results leading to
____________________.
|
|
|
32.
|
In a compound statement, the entire segment of code between the { and } is
treated like a(n) ____________________.
|
|
|
33.
|
Selection statements permit a computer to make ____________________.
|
|
|
34.
|
A(n) ____________________ program is protected against most possible crashes
from bad data and unexpected values.
|
|
|
35.
|
You should generally avoid using ____________________ if statements if an
extended if statement can be used.
|
|
|
36.
|
A(n) ____________________ is an analysis of a program that attempts to verify
the correctness of program results.
|
|
|
37.
|
____________________ identifiers can have only the values true or false.
|
|
|
38.
|
The relational operator ____________________ means not equal.
|
|
|
39.
|
The Boolean operator that has the highest priority for evaluation is
____________________.
|
|
|
40.
|
If A is true and B is false, A ____________________ B is
true.
|
|
|
41.
|
A program that is protected from crashing if bad data is entered is said to be
____________________.
|
Short Answer
|
|
|
42.
|
Which C++ construct can be used to create a data type?
|
|
|
43.
|
How many different reserved words can be used in a switch statement?
|
|
|
44.
|
The default option in a switch statement prevents what?
|
|
|
45.
|
Which three types of compound statements can be applied when multiple selection
is required for solving a problem?
|
|
|
46.
|
What is the correct priority for evaluating relational operators?
|
|
|
47.
|
What does multiway selection mean?
|
|
|
48.
|
What does short-circuit evaluation mean?
|
|
|
49.
|
Even for ordinal data types, when should a switch statement not be
implemented?
|
|
|
50.
|
Write a program segment to print the value of H if the Boolean G is true.
|
|
|
51.
|
Write a program segment to skip three lines if the value of the integer variable
lineCount is greater than 64.
|
|
|
52.
|
Write a program segment to print the word "YES" if G is a positive
number.
|
|
|
53.
|
Write a program segment, using a switch statement, that meets these
requirements: If the value of the integer variable A is 2, square it. If it is 3, read a
new value for A. If it is 4 or 5, multiply it by 3 and print out the new value.
|
|
|
54.
|
Write the function header and implementation to accomplish each task that
follows: a function greaterOfTwo which returns the largest of the two integer values it is sent, and
if they are equal, returns a zero.
|
|
|
55.
|
Write the function header and implementation to accomplish each task as follows:
a function absValue which is passed two integers and returns the absolute difference between the two
values.
|
|
|
56.
|
Write the function header and implementation to accomplish each task as follows:
a function largerOfThree which is passed three real numbers and returns the largest value of the
three numbers.
|
Problem
|
|
|
57.
|
Rewrite the following switch statement with a nested
if. switch
(score) {
case 1 :
cout << "Poor";
break;
case 2 : cout <<
"Fair";
break;
case 3 : cout << "Average";
break; case 4
: cout << "Good";
break; case
5 : cout << "Excellent";
break;
}
|