Deck 4: Making Decisions

ملء الشاشة (f)
exit full mode
سؤال
It is illegal to use a block to contain a single statement.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The non-conditional Boolean logical inclusive OR operator is written as ____.

A) |
B) &&
C) &
D) ||
سؤال
In a decision structure, the if expression that precedes a block is called the ____ statement.

A) sequence
B) conditional
C) K & R
D) control
سؤال
Flowchart creators use diamond shapes to indicate alternative courses of action.
سؤال
In C#, a ____ is a collection of one or more statements contained within a pair of curly braces.

A) switch
B) block
C) sequence structure
D) decision structure
سؤال
You can use the conditional ____ operator when you want some action to occur even if only one of two conditions is true .

A) AND
B) OR
C) XOR
D) NOT
سؤال
In a switch statement, the keyword ____ starts the switch structure.

A) if
B) case
C) break
D) switch
سؤال
A(n) ____ statement is used to make a single-alternative decision.

A) switch
B) fork
C) if
D) if-else
سؤال
You can use the conditional ____ operator within a Boolean expression to determine whether two expressions are both true .

A) OR
B) AND
C) XOR
D) NOT
سؤال
The non-conditional Boolean logical AND operator is written as ____.

A) &&
B) |
C) &
D) ||
سؤال
The expressions in each part of a compound, conditional Boolean expression are evaluated only as much as necessary to determine whether the entire expression is true or false . This feature is called ____ evaluation.

A) sequential
B) sequence
C) smart
D) short-circuit
سؤال
When if-else statements are nested, each else is always paired with the most recent unpaired if .
سؤال
A ____ structure involves choosing between alternative courses of action based on some value within a program.

A) decision
B) sequence
C) literal
D) fixed
سؤال
You can combine as many AND and OR operators in an expression as needed.
سؤال
The conditional AND operator is written as ____.

A) ||
B) |
C) &&
D) &
سؤال
The conditional OR operator is written as ____.

A) &
B) |
C) &&
D) ||
سؤال
In a switch statement, the keyword return usually terminates each case.
سؤال
When creating a flowchart or pseudocode representation of a task, a ____ structure is one in which one step follows another unconditionally.

A) single-decision
B) dual-decision
C) branched
D) sequence
سؤال
If you have a dual-alternative decision (you want to perform one action when a Boolean expression evaluates as true and an alternate action when it evaluates as false ), you can use a(n) ____ statement.

A) if-else
B) if
C) switch
D) fork
سؤال
In a switch statement, the keyword ____ is followed by one of the possible values that might equal the switch expression.

A) case
B) default
C) break
D) switch
سؤال
Using a(n) ____ with a switch statement can often be convenient because it can make the meaning of case label values much clearer.

A) if structure
B) OR
C) enumeration
D) conditional AND
سؤال
In a switch statement, the type of the value in a case label is the ____________________ type.
سؤال
A(n) ____________________ is similar to pseudocode, but you write the steps in diagram form, as a series of shapes connected by arrows.
سؤال
Why are all computer decisions true-or-false decisions?
سؤال
Explain why the following code sample does not capture the intent of the request "Make sure if the sales code is not 'A' or 'B', the customer gets a 10% discount". What is the correct if statement?
if (salesCode != 'A' || salesCode != 'B')
discount = 0.10;
سؤال
Describe how short-circuit evaluation works when evaluating compound Boolean expressions. Show an example.
سؤال
The ____________________ structure, an alternative to nested if statements, tests a single variable against a series of exact matches.
سؤال
In C#, the ____ operator is used as an abbreviated version of the if-else statement.

A) switch
B) NOT
C) conditional
D) XOR
سؤال
What is the difference between the conditional AND and OR operators and their logical counterparts? How can incorrect use of the logical operators lead to unintended consequences in your program?
سؤال
Explain (in words) how bonuses are assigned in the following example:
if (saleAmount > 1000)
if (saleAmount
bonus = 100;
else
bonus = 50;
سؤال
The optional keyword ____ is used prior to any action that should occur if the test expression does not match any case.

A) break
B) switch
C) default
D) else
سؤال
List the four keywords used in a switch structure and provide a brief description of each.
سؤال
Programmers often use ____________________, a tool that helps them plan a program's logic by writing plain English statements.
سؤال
What are four of the most frequent errors new programmers make when they first learn to make decisions?
سؤال
The following range-checking code works but is somewhat inefficient. Explain why and show how to revise it to be more efficient.
if (saleAmount >= 1000)
commissionRate = 0.08;
else if (saleAmount >= 500)
commissionRate = 0.06;
else if (saleAmount
commissionRate = 0.05;
سؤال
A(n) ____________________ decision has two possible resulting actions.
سؤال
In C#, an error occurs if you reach the end point of the statement list in a case section. This is known as the ____ rule.

A) no fall through
B) en passant
C) break on end
D) default
سؤال
What is the syntax of the conditional operator? Describe how the operator is used.
سؤال
The conditional operator ?: is a(n) ____ operator.

A) binary
B) ternary
C) unary
D) enumeration
سؤال
The NOT operator is written as ____.

A) &
B) &&
C) $
D) !
سؤال
Match between columns
Negates the result of any Boolean expression
side effect
Negates the result of any Boolean expression
switch expression
Negates the result of any Boolean expression
conditional operator
Negates the result of any Boolean expression
nested if
Negates the result of any Boolean expression
range check
Negates the result of any Boolean expression
case label
Negates the result of any Boolean expression
enumeration
Negates the result of any Boolean expression
NOT operator
Negates the result of any Boolean expression
truth table
Identifies a course of action in a switch structure
side effect
Identifies a course of action in a switch structure
switch expression
Identifies a course of action in a switch structure
conditional operator
Identifies a course of action in a switch structure
nested if
Identifies a course of action in a switch structure
range check
Identifies a course of action in a switch structure
case label
Identifies a course of action in a switch structure
enumeration
Identifies a course of action in a switch structure
NOT operator
Identifies a course of action in a switch structure
truth table
A statement in which one decision structure is contained within another
side effect
A statement in which one decision structure is contained within another
switch expression
A statement in which one decision structure is contained within another
conditional operator
A statement in which one decision structure is contained within another
nested if
A statement in which one decision structure is contained within another
range check
A statement in which one decision structure is contained within another
case label
A statement in which one decision structure is contained within another
enumeration
A statement in which one decision structure is contained within another
NOT operator
A statement in which one decision structure is contained within another
truth table
A diagram used to describe the Boolean value of an entire compound expression
side effect
A diagram used to describe the Boolean value of an entire compound expression
switch expression
A diagram used to describe the Boolean value of an entire compound expression
conditional operator
A diagram used to describe the Boolean value of an entire compound expression
nested if
A diagram used to describe the Boolean value of an entire compound expression
range check
A diagram used to describe the Boolean value of an entire compound expression
case label
A diagram used to describe the Boolean value of an entire compound expression
enumeration
A diagram used to describe the Boolean value of an entire compound expression
NOT operator
A diagram used to describe the Boolean value of an entire compound expression
truth table
The only ternary operator in C#
side effect
The only ternary operator in C#
switch expression
The only ternary operator in C#
conditional operator
The only ternary operator in C#
nested if
The only ternary operator in C#
range check
The only ternary operator in C#
case label
The only ternary operator in C#
enumeration
The only ternary operator in C#
NOT operator
The only ternary operator in C#
truth table
A series of if statements that determine whether a value falls within a specified range
side effect
A series of if statements that determine whether a value falls within a specified range
switch expression
A series of if statements that determine whether a value falls within a specified range
conditional operator
A series of if statements that determine whether a value falls within a specified range
nested if
A series of if statements that determine whether a value falls within a specified range
range check
A series of if statements that determine whether a value falls within a specified range
case label
A series of if statements that determine whether a value falls within a specified range
enumeration
A series of if statements that determine whether a value falls within a specified range
NOT operator
A series of if statements that determine whether a value falls within a specified range
truth table
An unintended consequence
side effect
An unintended consequence
switch expression
An unintended consequence
conditional operator
An unintended consequence
nested if
An unintended consequence
range check
An unintended consequence
case label
An unintended consequence
enumeration
An unintended consequence
NOT operator
An unintended consequence
truth table
Allows you to assign values to a list of constants
side effect
Allows you to assign values to a list of constants
switch expression
Allows you to assign values to a list of constants
conditional operator
Allows you to assign values to a list of constants
nested if
Allows you to assign values to a list of constants
range check
Allows you to assign values to a list of constants
case label
Allows you to assign values to a list of constants
enumeration
Allows you to assign values to a list of constants
NOT operator
Allows you to assign values to a list of constants
truth table
A test expression in a switch structure
side effect
A test expression in a switch structure
switch expression
A test expression in a switch structure
conditional operator
A test expression in a switch structure
nested if
A test expression in a switch structure
range check
A test expression in a switch structure
case label
A test expression in a switch structure
enumeration
A test expression in a switch structure
NOT operator
A test expression in a switch structure
truth table
سؤال
You write a program in which the user must select whether to receive instructions in English or Spanish. In a console application, you would issue the prompt:
Which language do you prefer? Enter 1 for English or 2 for Spanish >>
The program would accept the user's entry, make a decision, and take appropriate action. How would you commonly handle this decision-making situation in a GUI application?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Making Decisions
1
It is illegal to use a block to contain a single statement.
False
2
The non-conditional Boolean logical inclusive OR operator is written as ____.

A) |
B) &&
C) &
D) ||
A
3
In a decision structure, the if expression that precedes a block is called the ____ statement.

A) sequence
B) conditional
C) K & R
D) control
D
4
Flowchart creators use diamond shapes to indicate alternative courses of action.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
5
In C#, a ____ is a collection of one or more statements contained within a pair of curly braces.

A) switch
B) block
C) sequence structure
D) decision structure
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
6
You can use the conditional ____ operator when you want some action to occur even if only one of two conditions is true .

A) AND
B) OR
C) XOR
D) NOT
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
7
In a switch statement, the keyword ____ starts the switch structure.

A) if
B) case
C) break
D) switch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
8
A(n) ____ statement is used to make a single-alternative decision.

A) switch
B) fork
C) if
D) if-else
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
9
You can use the conditional ____ operator within a Boolean expression to determine whether two expressions are both true .

A) OR
B) AND
C) XOR
D) NOT
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
10
The non-conditional Boolean logical AND operator is written as ____.

A) &&
B) |
C) &
D) ||
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
11
The expressions in each part of a compound, conditional Boolean expression are evaluated only as much as necessary to determine whether the entire expression is true or false . This feature is called ____ evaluation.

A) sequential
B) sequence
C) smart
D) short-circuit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
12
When if-else statements are nested, each else is always paired with the most recent unpaired if .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
13
A ____ structure involves choosing between alternative courses of action based on some value within a program.

A) decision
B) sequence
C) literal
D) fixed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
14
You can combine as many AND and OR operators in an expression as needed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
15
The conditional AND operator is written as ____.

A) ||
B) |
C) &&
D) &
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
16
The conditional OR operator is written as ____.

A) &
B) |
C) &&
D) ||
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
17
In a switch statement, the keyword return usually terminates each case.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
18
When creating a flowchart or pseudocode representation of a task, a ____ structure is one in which one step follows another unconditionally.

A) single-decision
B) dual-decision
C) branched
D) sequence
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
19
If you have a dual-alternative decision (you want to perform one action when a Boolean expression evaluates as true and an alternate action when it evaluates as false ), you can use a(n) ____ statement.

A) if-else
B) if
C) switch
D) fork
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
20
In a switch statement, the keyword ____ is followed by one of the possible values that might equal the switch expression.

A) case
B) default
C) break
D) switch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
21
Using a(n) ____ with a switch statement can often be convenient because it can make the meaning of case label values much clearer.

A) if structure
B) OR
C) enumeration
D) conditional AND
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
22
In a switch statement, the type of the value in a case label is the ____________________ type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
23
A(n) ____________________ is similar to pseudocode, but you write the steps in diagram form, as a series of shapes connected by arrows.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
24
Why are all computer decisions true-or-false decisions?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
25
Explain why the following code sample does not capture the intent of the request "Make sure if the sales code is not 'A' or 'B', the customer gets a 10% discount". What is the correct if statement?
if (salesCode != 'A' || salesCode != 'B')
discount = 0.10;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
26
Describe how short-circuit evaluation works when evaluating compound Boolean expressions. Show an example.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
27
The ____________________ structure, an alternative to nested if statements, tests a single variable against a series of exact matches.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
28
In C#, the ____ operator is used as an abbreviated version of the if-else statement.

A) switch
B) NOT
C) conditional
D) XOR
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
29
What is the difference between the conditional AND and OR operators and their logical counterparts? How can incorrect use of the logical operators lead to unintended consequences in your program?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
30
Explain (in words) how bonuses are assigned in the following example:
if (saleAmount > 1000)
if (saleAmount
bonus = 100;
else
bonus = 50;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
31
The optional keyword ____ is used prior to any action that should occur if the test expression does not match any case.

A) break
B) switch
C) default
D) else
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
32
List the four keywords used in a switch structure and provide a brief description of each.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
33
Programmers often use ____________________, a tool that helps them plan a program's logic by writing plain English statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
34
What are four of the most frequent errors new programmers make when they first learn to make decisions?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
35
The following range-checking code works but is somewhat inefficient. Explain why and show how to revise it to be more efficient.
if (saleAmount >= 1000)
commissionRate = 0.08;
else if (saleAmount >= 500)
commissionRate = 0.06;
else if (saleAmount
commissionRate = 0.05;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
36
A(n) ____________________ decision has two possible resulting actions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
37
In C#, an error occurs if you reach the end point of the statement list in a case section. This is known as the ____ rule.

A) no fall through
B) en passant
C) break on end
D) default
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
38
What is the syntax of the conditional operator? Describe how the operator is used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
39
The conditional operator ?: is a(n) ____ operator.

A) binary
B) ternary
C) unary
D) enumeration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
40
The NOT operator is written as ____.

A) &
B) &&
C) $
D) !
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
Negates the result of any Boolean expression
side effect
Negates the result of any Boolean expression
switch expression
Negates the result of any Boolean expression
conditional operator
Negates the result of any Boolean expression
nested if
Negates the result of any Boolean expression
range check
Negates the result of any Boolean expression
case label
Negates the result of any Boolean expression
enumeration
Negates the result of any Boolean expression
NOT operator
Negates the result of any Boolean expression
truth table
Identifies a course of action in a switch structure
side effect
Identifies a course of action in a switch structure
switch expression
Identifies a course of action in a switch structure
conditional operator
Identifies a course of action in a switch structure
nested if
Identifies a course of action in a switch structure
range check
Identifies a course of action in a switch structure
case label
Identifies a course of action in a switch structure
enumeration
Identifies a course of action in a switch structure
NOT operator
Identifies a course of action in a switch structure
truth table
A statement in which one decision structure is contained within another
side effect
A statement in which one decision structure is contained within another
switch expression
A statement in which one decision structure is contained within another
conditional operator
A statement in which one decision structure is contained within another
nested if
A statement in which one decision structure is contained within another
range check
A statement in which one decision structure is contained within another
case label
A statement in which one decision structure is contained within another
enumeration
A statement in which one decision structure is contained within another
NOT operator
A statement in which one decision structure is contained within another
truth table
A diagram used to describe the Boolean value of an entire compound expression
side effect
A diagram used to describe the Boolean value of an entire compound expression
switch expression
A diagram used to describe the Boolean value of an entire compound expression
conditional operator
A diagram used to describe the Boolean value of an entire compound expression
nested if
A diagram used to describe the Boolean value of an entire compound expression
range check
A diagram used to describe the Boolean value of an entire compound expression
case label
A diagram used to describe the Boolean value of an entire compound expression
enumeration
A diagram used to describe the Boolean value of an entire compound expression
NOT operator
A diagram used to describe the Boolean value of an entire compound expression
truth table
The only ternary operator in C#
side effect
The only ternary operator in C#
switch expression
The only ternary operator in C#
conditional operator
The only ternary operator in C#
nested if
The only ternary operator in C#
range check
The only ternary operator in C#
case label
The only ternary operator in C#
enumeration
The only ternary operator in C#
NOT operator
The only ternary operator in C#
truth table
A series of if statements that determine whether a value falls within a specified range
side effect
A series of if statements that determine whether a value falls within a specified range
switch expression
A series of if statements that determine whether a value falls within a specified range
conditional operator
A series of if statements that determine whether a value falls within a specified range
nested if
A series of if statements that determine whether a value falls within a specified range
range check
A series of if statements that determine whether a value falls within a specified range
case label
A series of if statements that determine whether a value falls within a specified range
enumeration
A series of if statements that determine whether a value falls within a specified range
NOT operator
A series of if statements that determine whether a value falls within a specified range
truth table
An unintended consequence
side effect
An unintended consequence
switch expression
An unintended consequence
conditional operator
An unintended consequence
nested if
An unintended consequence
range check
An unintended consequence
case label
An unintended consequence
enumeration
An unintended consequence
NOT operator
An unintended consequence
truth table
Allows you to assign values to a list of constants
side effect
Allows you to assign values to a list of constants
switch expression
Allows you to assign values to a list of constants
conditional operator
Allows you to assign values to a list of constants
nested if
Allows you to assign values to a list of constants
range check
Allows you to assign values to a list of constants
case label
Allows you to assign values to a list of constants
enumeration
Allows you to assign values to a list of constants
NOT operator
Allows you to assign values to a list of constants
truth table
A test expression in a switch structure
side effect
A test expression in a switch structure
switch expression
A test expression in a switch structure
conditional operator
A test expression in a switch structure
nested if
A test expression in a switch structure
range check
A test expression in a switch structure
case label
A test expression in a switch structure
enumeration
A test expression in a switch structure
NOT operator
A test expression in a switch structure
truth table
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
42
You write a program in which the user must select whether to receive instructions in English or Spanish. In a console application, you would issue the prompt:
Which language do you prefer? Enter 1 for English or 2 for Spanish >>
The program would accept the user's entry, make a decision, and take appropriate action. How would you commonly handle this decision-making situation in a GUI application?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.