Decision Structures and Boolean Logic Flashcards
What is another term for a decision structure?
Selection structure.
What is the role of conditionals in decision structures?
They control which statements are executed based on whether a condition is true or false.
How are decision structures combined in logical design?
They are used alongside sequence structures.
What keywords are used in pseudocode for a simple decision structure?
If-Then, End If.
What is a Boolean expression?
An expression that evaluates to either true or false.
Who introduced Boolean logic, and when?
George Boole in the 1800s.
What does the relational operator > indicate?
Greater than.
What does the relational operator <= mean?
Less than or equal to.
What is the difference between = and == in programming?
= is an assignment operator, while == checks for equality.
What does the != operator represent?
Not equal to.
How do dual alternative decision structures operate?
By executing different groups of statements depending on whether the Boolean expression is true or false.
What pseudocode structure represents dual alternative decisions?
If-Then-Else.
How are strings compared in programming?
By evaluating their character codes (e.g., ASCII codes) one by one.
What is a nested decision structure?
A decision structure placed inside another decision structure.
Why is the If-Then-Else If structure preferred over nested decision structures?
It is simpler to read.
What is a Case structure used for?
To determine program execution paths based on specific values or expressions.
How does the AND operator work in Boolean logic?
It returns true only if both subexpressions are true.
When does the OR operator return false?
When both subexpressions are false.
What does the NOT operator do?
Reverses the logical value of an expression.
How can logical operators check if a number is within a range?
Use the AND operator: If x >= low AND x <= high Then
What does short-circuit evaluation mean in Boolean logic?
Evaluating a compound expression by stopping as soon as the outcome is determined.
In short-circuit evaluation, which subexpression should come first with the AND operator?
The one most likely to be false.
What is a Boolean variable?
A variable that can hold either true or false.
How can logical operators check if a value is outside a range?
Use the OR operator: If x < low OR x > high Then