The way statements are sequenced and combined in a program determines the computed result. Programs incorporate selection constructs to make decisions to handle varied input values.
How can we store data in a program to solve problems?
What might happen if you completed the steps in your regular morning routine to get ready and go to school in a different order? How might the reordering affect the decisions you make each morning?
How do video games group different actions for a player based on what key is pressed on the keyboard or controller? How do apps group different actions together based on user interaction, such as pressing buttons?
What types of problems can be solved more easily with a computer, and what types can be solved more easily without a computer? Why?
Express an algorithm that uses selection without using a programming language.
Write conditional statements.
Determine the result of conditional statements.
For nested selection:
Write nested conditional statements.
Determine the result of nested conditional statements.
Selection determines which parts of an algorithm are executed based on a condition being true or false.
Conditional statements or “if-statements” affect the sequential flow of control by executing different statements based on the value of a Boolean expression.
Nested conditional statements consist of conditional statements within conditional statements.