You are on page 1of 37

Chapter 4

Review Question

Multiple Choice

1. A _________ structure can execute a set of statements only under certain circumstances.
C. decision
2. A _________ structure provides one alternative path of execution.
B. single alternative decision
3. In pseudocode, the If-Then statement us an example of a _________.
B. decision structure
4. A (n) _________ expression has a value of either true or false.
D. Boolean
5. The symbols >, <, and == are all _________ operators.
A. relational
6. A (n) _________ structure tests a condition and then takes one path is the condition is true, or
another path if the condition is false.
C. Dual alternative decision
7. You use a (n) _________ statement in pseudocode to write a single alternative decision
structure.
B. If-Then
8. You use a (n) _________ statement in pseudocode to write a dual alternative decision structure.
C. If-Then-Else
9. A _________ structure allows you to test the value of a variable or an expression and then use
that value to determine which statement or set of statements to execute.
D. multiple alternative decision
10. A (n) _________ section of a Select Case statement is branched to if none of the case values
match the expression listed after the Select statement.
B. Default
11. AND, OR, and NOT are _________ operators.
B. logical
12. A compound Boolean expression created with the _________ operator is true only if both of its
subexpressions are true.
A. AND
13. A compound Boolean expression created with the _________ operator is true if either of its
subexpressions is true.
B. OR
14. The _________ operator takes a Boolean expression as its operand and reverses its logical value.
C. NOT
15. A _________ is a Boolean variable that signals when some condition exists in the program.

A. Fla
True or false

1. You can write any program using only sequence structures


True
2. A program can be made of only one type of control structure. You cannot combine structures.
False
3. A single alternative decision structure tests a condition and then takes one path if the condition
is true, or another path if the condition is false.
False
4. A decision structure can be nested inside another decision structure.
True
5. A compound Boolean expression created with the AND operator is true only when both sub-
expressions are true.
True

Short answer
1. Explain what is meant by the term “conditionally executed.”
An action is performed only when a certain condition is true

 Conditionally executed is called a single alternative decision structure Because It


Provides only one alternative path of execution. The action is conditionally executed
is Performed Because It Only When to Uncertain condition is true.
2. You need to test a condition and then execute one set of statements if the condition is
True. If the condition is false, you need to execute a different set of statements. What
Structure will you use?
I would use a dual decision structure so that if the statement were true it would travel one
path, if false it would go the other path.

 I will use the "If" statement because it is a dual alternative decision structure.
3. If you need to test the value of a variable and use value to determine That Which statement or
set of statements to execute, Which structure would be The most straightforward to use?

A nested decision structure would be the most straightforward to use. It tests the value of a
variable and uses that value to determine which statements or set of statement to execute

 The case structure lets the value of an expression or variable determines which
execution path of the program will take.
4. Briefly describe how the AND operator works.
The AND operator connects two Boolean expressions into one compound expression. Both
subexpressions must the true for the compound expression to be true.
 The AND operator takes two Boolean expressions as operands and Creates a
compound Boolean expression is True That Only When Both sub-expressions are
true. The following is an example of an If-Then statement uses the AND operator
that:

If temperature <20 AND minutes> 12 Then


Display "The temperature is in the danger zone."
End If

5. Briefly describe how the OR operator works.

The OR operator connects two Boolean expressions into one compound expression. One or
both subexpressions must be true for the compound expression to be true. It is only necessary
for one of the subexpressions to be true, and it does not matter which.

 The OR operator takes two Boolean expressions as operands and Creates a


compound Boolean expression is true That When Either of the sub-expressions is
true. The following is an example of an If-Then statement uses the OR That
operator:

If temperature <20 OR temperature> 100 Then


Display "The temperature is in the danger zone."
End If

6. When determining whether a number is inside a range, which logical operator is it best to
use?
And operator


The AND operator would be the best to use to determine whether or not a number
is Within a Given Range.
7. What is a flag and how does it work?

 A flag is a Boolean variable signals That When some condition exists in the program.
When the flag is September to False, it Indicates the condition does not exist. When
the flag is September Variable to True, It Means the condition does exist.
8. Isaac
9. Anaza
10. Gas
11. Ty
Chapter 5

Multiple Choice

1. A _____-controlled loop uses a true/false condition to control the number of times that it
repeats
B. condition
2. A _____-controlled loop repeats a specific number of times.
D. count
3. Each repetition of a loop is known as a(n) _____.
D. iteration
4. The while loop is a _____ type of loop.
A. pretest

5.
6. Mn
7. M
8. M
9. M
10. M
11. ,
12. ,
13. ,
14. ,
15. .
16. ,
17. ,

You might also like