Fiveable
Fiveable

Selection

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.

Analogy

Think of selection as choosing what clothes to wear based on the weather outside. If it's sunny, you might wear shorts and a t-shirt, but if it's raining, you'll grab an umbrella and put on a raincoat.

Related terms

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.



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.