Decision Structures and Boolean Logic Flashcards
What is a selection structure?
A selection structure controls statement execution based on conditions.
What determines the execution flow in decision structures?
True/False evaluation.
What is the role of conditionals in decision structures?
Conditionals execute statements only if conditions are met.
How do decision structures combine with sequence structures?
Decision structures are used alongside sequence structures to control execution flow.
What is the basic structure of an If-Then statement in pseudocode?
An If-Then structure contains a condition and associated statements, ending with “End If”.
What are Boolean expressions used for?
Boolean expressions evaluate to true or false.
What do relational operators do?
Relational operators compare two values.
What relational operator is used for equality comparison?
== is used for equality comparison.
What is the purpose of the If-Then-Else structure?
It executes one block if true and another if false.
How are strings compared in decision structures?
Strings are compared using ASCII codes, character by character.
What are nested decision structures?
They are decisions inside another decision, testing multiple conditions.
What is the advantage of using an If-Then-Else If structure?
It improves readability over nested If-Then structures.
What is the case structure in decision making?
A switch-like structure where the execution path depends on a matching value or expression.
What does the AND logical operator require in a compound expression?
Both conditions must be true.
What is short-circuit evaluation in logical operators?
It optimizes performance by evaluating the most likely condition first.
How do you check if a value is inside a range using logical operators?
Use AND to check if a value is within a range, e.g., If x >= 20 AND x <= 40.
How do you check if a value is outside a range using logical operators?
Use OR to check if a value is outside a range, e.g., If x < 20 OR x > 40.
What are Boolean variables used for?
Boolean variables hold true/false values and are used as flags to track conditions.
How do you set a Boolean variable based on a condition?
Set a Boolean variable to True or False based on the condition, e.g., Set salesQuotaMet = True.