Control Structures - Selection
Selection control structures, like if-else statements, let a program choose different actions based on whether a condition is true or false.
Core concept
An if statement executes code only if a condition is true, like 'if (score > 50) print Pass'.
How it works
An if-else statement provides an alternative action if the condition is false, like showing 'Fail' if the score isn't above 50.
Why it matters
A switch statement is useful when checking one variable against multiple possible values, offering a cleaner alternative to many if-else statements.
Key detail
Understanding selection structures is essential for creating programs that respond differently based on varying conditions.
Exam highlight
Key diagram

Keywords worth remembering
Trending
Most searched
Quick revision
Study resources
Notes & downloads
Quick notes
• An if statement runs code only if true.
• Example: if score>50, print Pass.
• If-else adds an alternative for false conditions.
• It shows Fail if score isn't above 50.
• A switch statement checks multiple possible values.
• It's cleaner than many if-else statements.
• Selection structures let programs make decisions.
• This is essential for varied program responses.