Deck 4: Selection Structures

Full screen (f)
exit full mode
Question
Using nested if statements without including braces to indicate the structure constitutes a common programming error.
Use Space or
up arrow
down arrow
to flip the card.
Question
In C++, when comparing character data, the char values are coerced to ____ values automatically for the comparison.

A) bool
B) unsigned int
C) long
D) int
Question
In a relational expression, the value of the expression can be only the integer value 1 or ____.

A) -10
B) -1
C) 0
D) 10
Question
Before the current ANSI/ISO C++ standard, C++ didn t have a built-in Boolean data type with its two Boolean values, true and false .
Question
The case keyword identifies the start of the switch statement.
Question
A switch statement can contain any number of case labels in any order.
Question
A common problem with the if-else statement is using the assignment operator, = , in place of the relational operator == .
Question
Logical operators AND, OR, and NOT are represented by the symbols , ____, and !, respectively.

A) >>
B) ||
C) <<
D) |
Question
The switch statement requires you to terminate each case with a break statement.
Question
In C++, the postfix and prefix -- operators can be applied to Boolean variables.
Question
In C++, strings of characters cannot be compared.
Question
In C++, the logical ____ operator is used to change an expression to its opposite state.

A) AND
B) OR
C) NOT
D) REVERSE
Question
Using the abs() function requires including the ____ header file.

A) cnumber
B) iostream
C) math
D) cmath
Question
The ____ statement in C++ is used to implement a decision structure in its simplest form choosing between two alternatives.

A) for
B) if-else
C) switch-case
D) while
Question
The switch statement requires you to list the case values in increasing order.
Question
In C++, two string expressions can be compared by using relational operators or the ____ class s comparison methods.

A) string
B) boolean
C) object
D) compareTo
Question
The most commonly used ____ in if statements are simple relational expressions.

A) conditions
B) comments
C) evaluations
D) branches
Question
A ____ relational expression consists of a relational operator that compares two operands.

A) single
B) complex
C) composed
D) simple
Question
The condition used in an if statement can be any valid C++ expression.
Question
One or more if-else statements can be included in either part of an if-else statement.
Question
The relational operator ____ is used to represent the condition less than.

A) >
B) <
C) <=
D) <<
Question
A ____ statement is an alternative to the if-else chain for situations when the condition involves comparing an integer expression to a specific value.

A) switch
B) for
C) while
D) do-while
Question
A ____ statement is a sequence of single statements contained between braces.

A) compound
B) single
C) simple
D) complex
Question
A(n) ____ chain is used in programming applications where one set of instructions must be selected from many possible alternatives.

A) break
B) case
C) for
D) if-else
Question
In the switch statement, the ____ keyword identifies values that are compared with the switch expression s value.

A) default
B) break
C) case
D) label
Question
A useful modification of the if-else statement involves omitting the ____ part of the statement.

A) expression
B) endif
C) else
D) if
Question
Applying a postfix or prefix ++ operator to a variable of type bool sets the Boolean value to ____.

A) false
B) true
C) yes
D) correct
Question
With ____, the program includes code to check for improper data before an attempt is made to process it further.

A) defensive programming
B) bug tracking
C) debugging
D) self-cleaning
Question
A(n) ____ is any combination of operands and operators that yields a result.

A) command
B) expression
C) sentence
D) statement
Question
Like all C++ expressions, relational expressions are evaluated to yield a(n) ____________________ result.
Question
When the ____________________ logical operator is used with two simple expressions, the condition is true only if both individual expressions are true by themselves.
Question
In C++, relational operators can be used with integer, float, double, and ____________________ operands.
Question
In the ASCII character set, lowercase letters are considered ____________________ than uppercase letters.
Question
Including one or more if statements inside an existing if statement is called a ____ if statement.

A) composed
B) complex
C) compound
D) nested
Question
The area in a program where a variable can be used is formally referred to as the ____ of the variable.

A) spread
B) block
C) reach
D) scope
Question
In C++, Boolean variables are declared with the ____ keyword.

A) boolean
B) false
C) bool
D) true
Question
The expression in the switch statement must evaluate to a(n) ____ result or a compilation error results.

A) character
B) boolean
C) integer
D) long
Question
When writing a switch statement, you can use multiple ____ values to refer to the same set of statements.

A) boolean
B) default
C) break
D) case
Question
Checking user input data for erroneous or unreasonable data is referred to as ____.

A) relational data validation
B) arithmetic data validation
C) output data validation
D) input data validation
Question
The ____ statement identifies the end of a particular case and causes an immediate exit from the switch statement.

A) default
B) break
C) stop
D) exit
Question
In the switch statement, the ____________________ keyword identifies values that are compared with the switch expression s value.
Question
If ____________________ statements are omitted in a switch statement, all cases following the matching case value, including the default case, are executed.
Question
An if-else statement without an else part is called a(n) ____________________ if statement.
Question
The if-else statement is written: if (expression) statement1; else statement2; . If the value of expression is non-zero, ____________________ will be executed.
Question
The technique of ____________________ programming includes code to check for improper input data.
Question
Including one or more if statements inside an existing if statement is called a(n) ____________________ if statement.
Question
Any variable declared within a block of statements has meaning only between its ____________________ and the closing braces defining the block.
Question
Because of the way computers store single-precision and double-precision numbers, you should avoid testing for equality of single-precision and double-precision values and variables by using the relational operator ____________________.
Question
A(n) ____________________ statement is a sequence of single statements between braces.
Question
The ____________________ keyword is optional in a switch statement.
Question
Because the NOT operator is used with only one expression, it is a(n) ____________________ operator.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: Selection Structures
1
Using nested if statements without including braces to indicate the structure constitutes a common programming error.
True
2
In C++, when comparing character data, the char values are coerced to ____ values automatically for the comparison.

A) bool
B) unsigned int
C) long
D) int
D
3
In a relational expression, the value of the expression can be only the integer value 1 or ____.

A) -10
B) -1
C) 0
D) 10
C
4
Before the current ANSI/ISO C++ standard, C++ didn t have a built-in Boolean data type with its two Boolean values, true and false .
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
The case keyword identifies the start of the switch statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
A switch statement can contain any number of case labels in any order.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
A common problem with the if-else statement is using the assignment operator, = , in place of the relational operator == .
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
Logical operators AND, OR, and NOT are represented by the symbols , ____, and !, respectively.

A) >>
B) ||
C) <<
D) |
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
The switch statement requires you to terminate each case with a break statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
10
In C++, the postfix and prefix -- operators can be applied to Boolean variables.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
In C++, strings of characters cannot be compared.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
In C++, the logical ____ operator is used to change an expression to its opposite state.

A) AND
B) OR
C) NOT
D) REVERSE
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
Using the abs() function requires including the ____ header file.

A) cnumber
B) iostream
C) math
D) cmath
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
The ____ statement in C++ is used to implement a decision structure in its simplest form choosing between two alternatives.

A) for
B) if-else
C) switch-case
D) while
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
The switch statement requires you to list the case values in increasing order.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
In C++, two string expressions can be compared by using relational operators or the ____ class s comparison methods.

A) string
B) boolean
C) object
D) compareTo
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
The most commonly used ____ in if statements are simple relational expressions.

A) conditions
B) comments
C) evaluations
D) branches
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
A ____ relational expression consists of a relational operator that compares two operands.

A) single
B) complex
C) composed
D) simple
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
The condition used in an if statement can be any valid C++ expression.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
One or more if-else statements can be included in either part of an if-else statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
The relational operator ____ is used to represent the condition less than.

A) >
B) <
C) <=
D) <<
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
A ____ statement is an alternative to the if-else chain for situations when the condition involves comparing an integer expression to a specific value.

A) switch
B) for
C) while
D) do-while
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
A ____ statement is a sequence of single statements contained between braces.

A) compound
B) single
C) simple
D) complex
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
A(n) ____ chain is used in programming applications where one set of instructions must be selected from many possible alternatives.

A) break
B) case
C) for
D) if-else
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
In the switch statement, the ____ keyword identifies values that are compared with the switch expression s value.

A) default
B) break
C) case
D) label
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
A useful modification of the if-else statement involves omitting the ____ part of the statement.

A) expression
B) endif
C) else
D) if
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
Applying a postfix or prefix ++ operator to a variable of type bool sets the Boolean value to ____.

A) false
B) true
C) yes
D) correct
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
With ____, the program includes code to check for improper data before an attempt is made to process it further.

A) defensive programming
B) bug tracking
C) debugging
D) self-cleaning
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
A(n) ____ is any combination of operands and operators that yields a result.

A) command
B) expression
C) sentence
D) statement
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
Like all C++ expressions, relational expressions are evaluated to yield a(n) ____________________ result.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
When the ____________________ logical operator is used with two simple expressions, the condition is true only if both individual expressions are true by themselves.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
In C++, relational operators can be used with integer, float, double, and ____________________ operands.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
In the ASCII character set, lowercase letters are considered ____________________ than uppercase letters.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
Including one or more if statements inside an existing if statement is called a ____ if statement.

A) composed
B) complex
C) compound
D) nested
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
The area in a program where a variable can be used is formally referred to as the ____ of the variable.

A) spread
B) block
C) reach
D) scope
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
In C++, Boolean variables are declared with the ____ keyword.

A) boolean
B) false
C) bool
D) true
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
The expression in the switch statement must evaluate to a(n) ____ result or a compilation error results.

A) character
B) boolean
C) integer
D) long
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
When writing a switch statement, you can use multiple ____ values to refer to the same set of statements.

A) boolean
B) default
C) break
D) case
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
Checking user input data for erroneous or unreasonable data is referred to as ____.

A) relational data validation
B) arithmetic data validation
C) output data validation
D) input data validation
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
The ____ statement identifies the end of a particular case and causes an immediate exit from the switch statement.

A) default
B) break
C) stop
D) exit
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
In the switch statement, the ____________________ keyword identifies values that are compared with the switch expression s value.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
If ____________________ statements are omitted in a switch statement, all cases following the matching case value, including the default case, are executed.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
An if-else statement without an else part is called a(n) ____________________ if statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
The if-else statement is written: if (expression) statement1; else statement2; . If the value of expression is non-zero, ____________________ will be executed.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
The technique of ____________________ programming includes code to check for improper input data.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
Including one or more if statements inside an existing if statement is called a(n) ____________________ if statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
Any variable declared within a block of statements has meaning only between its ____________________ and the closing braces defining the block.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
Because of the way computers store single-precision and double-precision numbers, you should avoid testing for equality of single-precision and double-precision values and variables by using the relational operator ____________________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
A(n) ____________________ statement is a sequence of single statements between braces.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
The ____________________ keyword is optional in a switch statement.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
Because the NOT operator is used with only one expression, it is a(n) ____________________ operator.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 51 flashcards in this deck.