Programming ConceptsLesson 5Free preview
If Statements
This lesson is part of Intro to Programming · All levels
Summary
This lesson discusses the if statement, a branching instruction that runs a block of code only if a condition is worth true. Conditions are formed from a comparison expression that is always of true or false, and can be added else or else if for an alternative option. Branching enables the program to make decisions based on the data it processes.
Key points
- If running a block of code only when the condition is correct (true)
- Conditions come from comparisons such as ==, >, <, or!=
- Else provides an alternative branch when the condition false
- Else if allowing several branches of successive conditions
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.