Conditional statements or conditional control structures allow a program to have different behaviors depending on certain conditions being met.
Intuitively, this mimics the way humans make simple decisions and act upon them. For example, reasoning about whether to go outside might look like:
- Condition: Is it raining outside?
- If it is raining outside, then bring an umbrella.
- Otherwise, do not bring an umbrella.
We could keep adding clauses to make our reasoning more sophisticated, such as “If it is sunny, then wear sunscreen”.