Deck 4: Making Decisions
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
Match between columns
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/42
العب
ملء الشاشة (f)
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) |
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
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
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
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
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
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
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) ||
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
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
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) &
A) ||
B) |
C) &&
D) &
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
16
The conditional OR operator is written as ____.
A) &
B) |
C) &&
D) ||
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
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
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
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
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;
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
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;
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
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;
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
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
A) binary
B) ternary
C) unary
D) enumeration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
40
The NOT operator is written as ____.
A) &
B) &&
C) $
D) !
A) &
B) &&
C) $
D) !
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 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?
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

