Written by the Fiveable Content Team โข Last updated August 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated August 2025
Definition
Selection refers to the process of making a decision based on a condition or criteria. It allows the program to choose between different paths of execution.
Condition: A condition is a statement that evaluates to either true or false. It is used in selection statements to determine which path of execution should be taken.
If statement: An if statement is a type of selection statement that executes a block of code only if a certain condition is true.
Else statement: An else statement is used in conjunction with an if statement and executes a block of code when the condition in the if statement evaluates to false.