Selection

Cards (5)

  • Selection is a programming construct that allows a program to run sequences of code depending on whether a condition evaluates to True or False.
  • High-level programming languages implement selection using if statements.
  • Using else allows you to specify a sequence of code statements to run if the first condition evaluates to False.
  • You can introduce multiple checks using else if. The conditions must be specified in the order you want them to be checked and acted on.
  • Nested selection is used to implement branching logic. This means that if a condition of a main selection block evaluates to True, then it leads to sub-conditions (in the form of nested if statements), which are included inside the main condition.