Deck 4: Making Decisions
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/53
Play
Full screen (f)
Deck 4: Making Decisions
1
This operator represents the logical AND.
A)++
B)| |
C)&&
D)@
E)None of these
A)++
B)| |
C)&&
D)@
E)None of these
&&
2
What is the output of the following segment of code if the value 4 is input by the user when asked to enter a number?

A)0
B)3
C)13
D)28
E)None of these

A)0
B)3
C)13
D)28
E)None of these
13
3
This operator takes an operand and reverses its truth or falsehood.
A)| |
B)relational
C)arithmetic
D)!
E)None of these
A)| |
B)relational
C)arithmetic
D)!
E)None of these
!
4
When a relational expression is false, it has the value ________.
A)one
B)zero
C)zero, one, or minus one
D)less than zero
E)None of these
A)one
B)zero
C)zero, one, or minus one
D)less than zero
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
5
Whereas < is called a relational operator, x < y is called a(n)________.
A)Arithmetic operator
B)Relative operator
C)Relational expression
D)Largeness test
E)None of these
A)Arithmetic operator
B)Relative operator
C)Relational expression
D)Largeness test
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
6
What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables.
a = x >= y;
A)10
B)7
C)The string "x >= y"
D)1
E)0
a = x >= y;
A)10
B)7
C)The string "x >= y"
D)1
E)0
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
7
What will the following segment of code output?

A)You failed the test!
B)You passed the test!
C)You failed the test! You passed the test!
D)You failed the test! You did poorly on the test!
E)None of the above

A)You failed the test!
B)You passed the test!
C)You failed the test! You passed the test!
D)You failed the test! You did poorly on the test!
E)None of the above
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
8
Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression.
A)break
B)exit
C)switch
D)scope
E)None of these
A)break
B)exit
C)switch
D)scope
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
9
If you place a semicolon after the statement: if (x < y)
A)The code will not compile.
B)The compiler will interpret the semicolon as a null statement.
C)The if statement will always evaluate to false.
D)All of the above
E)None of these
A)The code will not compile.
B)The compiler will interpret the semicolon as a null statement.
C)The if statement will always evaluate to false.
D)All of the above
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
10
This is a variable, usually a bool or an int, that signals when a condition exists.
A)relational operator
B)arithmetic operator
C)flag
D)float
E)None of these
A)relational operator
B)arithmetic operator
C)flag
D)float
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
11
Assuming x is 5, y is 6, and z is 8, which of the following is false?

A)3, 4, 6, 7 are false.
B)Only 5 is false.
C)3 and 4 are false.
D)All are false.
E)None of these.

A)3, 4, 6, 7 are false.
B)Only 5 is false.
C)3 and 4 are false.
D)All are false.
E)None of these.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
12
This operator is used in C++ to represent equality.
A)=
B)><
C)!!
D)==
E)None of these
A)=
B)><
C)!!
D)==
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
13
What will be the output of the following code segment after the user enters 0 at the keyboard?

A)Nothing will be displayed.
B)false
C)x
D)true

A)Nothing will be displayed.
B)false
C)x
D)true
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
14
When an if statement is placed within the conditionally-executed code of another if statement, this is known as:
A)complexity
B)overloading
C)nesting
D)validation
E)None of these
A)complexity
B)overloading
C)nesting
D)validation
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
15
Input values should always be checked for:
A)Appropriate range
B)Reasonableness
C)Division by zero, if division is taking place
D)All of these
E)None of these
A)Appropriate range
B)Reasonableness
C)Division by zero, if division is taking place
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
16
After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time?

A)15
B)10
C)25
D)0
E)5

A)15
B)10
C)25
D)0
E)5
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
17
What will the following segment of code output?

A)This is a test question!
B)Congratulations! That's a high score! This is a test question!
C)That's a high score! This is a test question!
D)Congratulations! That's a high score!
E)None of these

A)This is a test question!
B)Congratulations! That's a high score! This is a test question!
C)That's a high score! This is a test question!
D)Congratulations! That's a high score!
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
18
This statement uses the value of a variable or expression to determine where the program will branch to.
A)switch
B)select
C)associative
D)scope
E)None of these
A)switch
B)select
C)associative
D)scope
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
19
Relational operators allow you to ________ numbers.
A)add
B)multiply
C)compare
D)average
E)None of these
A)add
B)multiply
C)compare
D)average
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
20
What is the output of the following code segment?

A)This is true!
B)This is false!
C)This is true! This is false!
D)This is true! This is all folks!
E)None of these

A)This is true!
B)This is false!
C)This is true! This is false!
D)This is true! This is all folks!
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
21
This operator is known as the logical OR operator.
A)--
B)//
C)#
D)||
E)None of these
A)--
B)//
C)#
D)||
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
22
When a program lets the user know that an invalid choice has been made, this is known as:
A)input validation
B)output correction
C)compiler criticism
D)output validation
E)None of these
A)input validation
B)output correction
C)compiler criticism
D)output validation
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
23
What will the following segment of code output if the value 11 is entered at the keyboard?

A)C++ is fun
B)Soccer is fun
C)C++
D)C++fun
E)Soccerfun

A)C++ is fun
B)Soccer is fun
C)C++
D)C++fun
E)Soccerfun
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
24
What will the following program display?

A)0 1 1 0
B)0 0 1 0
C)1 1 0 1
D)1 0 0 1
E)None of these

A)0 1 1 0
B)0 0 1 0
C)1 1 0 1
D)1 0 0 1
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
25
What will the following program segment display?

A)7 15
B)0 0
C)10 10
D)1 1
E)None of these

A)7 15
B)0 0
C)10 10
D)1 1
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
26
In C++ the = operator indicates:
A)equality
B)assignment
C)subtraction
D)negation
E)None of these
A)equality
B)assignment
C)subtraction
D)negation
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
27
Given that, x = 2, y = 1, and z = 0, what will the following cout statement display?

A)answer = 0
B)answer = 1
C)answer = 2
D)None of these

A)answer = 0
B)answer = 1
C)answer = 2
D)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
28
Given the following code segment, what is output after "result = "?

A)0
B)1
C)2
D)3
E)None of these

A)0
B)1
C)2
D)3
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
29
What is the value of the following expression?

A)true
B)false
C)-1
D)+1

A)true
B)false
C)-1
D)+1
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
30
What is the value of the following expression?

A)true
B)false
C)-1
D)+1

A)true
B)false
C)-1
D)+1
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
31
What is the value of the following expression?

A)true
B)false
C)-1
D)+1

A)true
B)false
C)-1
D)+1
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
32
This operator performs a logical NOT operation.
A)--
B)!
C)<>
D)><
E)None of these
A)--
B)!
C)<>
D)><
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
33
If you intend to place a block of statements within an if statement, you must place these around the block.
A)Parentheses ( )
B)Square brackets [ ]
C)Angle brackets < >
D)Curly braces { }
E)None of these
A)Parentheses ( )
B)Square brackets [ ]
C)Angle brackets < >
D)Curly braces { }
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
34
The ________ of a variable is limited to the block in which it is declared.
A)precedence
B)associativity
C)scope
D)branching ability
E)None of these
A)precedence
B)associativity
C)scope
D)branching ability
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
35
What is the value of donuts after the following code executes?

A)12
B)10
C)0
D)2

A)12
B)10
C)0
D)2
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
36
What is the value of the following expression?

A)true
B)false
C)-1
D)+1

A)true
B)false
C)-1
D)+1
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
37
The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.
A)conditional
B)break
C)trailing else
D)All of these
E)None of these
A)conditional
B)break
C)trailing else
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
38
Which statement allows you to properly check the char variable code to determine whether it is equal to a "C" and then output "This is a check" and then advance to a new line?
A)
B)
C)
D)
A)

B)

C)

D)

Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
39
These operators connect two or more relational expressions into one, or reverse the logic of an expression.
A)relational
B)logical
C)irrational
D)negation
E)None of these
A)relational
B)logical
C)irrational
D)negation
E)None of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
40
What is the value of donuts after the following code executes?

A)12
B)10
C)0
D)1

A)12
B)10
C)0
D)1
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
41
What will be the value of result after the following code has been executed?

A)10
B)120
C)20
D)This code will not compile.

A)10
B)120
C)20
D)This code will not compile.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
42
If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
43
Both of the following if statements perform the same operation.
if (sales > 10000)
commissionRate = 0.15;
if (sales > 10000)commissionRate = 0.15;
if (sales > 10000)
commissionRate = 0.15;
if (sales > 10000)commissionRate = 0.15;
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
44
You should be careful when using the equality operator to compare floating point values because of potential round-off errors.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
45
The following code correctly determines whether x contains a value in the range of 0 through 100.
if (x >= 0 && <= 100)
if (x >= 0 && <= 100)
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
46
Which of the following expressions will determine whether x is less than or equal to y?
A)x > y
B)x =< y
C)x <= y
D)x >= y
A)x > y
B)x =< y
C)x <= y
D)x >= y
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
47
The default section is required in a switch statement.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
48
Which value can be entered to cause the following code segment to display the message: 
A)100
B)10
C)99
D)0
E)All of these

A)100
B)10
C)99
D)0
E)All of these
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
49
An expression that has any value other than 0 is considered true by an if statement.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
50
What is the output of the following code?

A)98
B)99
C)0
D)1

A)98
B)99
C)0
D)1
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
51
As a rule of style, when writing an if statement you should indent the conditionally-executed statements.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
52
Which line in the following program will cause a compiler error?

A)6
B)8
C)10
D)9

A)6
B)8
C)10
D)9
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
53
If the sub-expression on the left side of an && operator is false, the expression on the right side will not be checked.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck