Conditionals
Learn how to make decisions in your programs using if statements and conditional logic.
Proper nesting
Each nested if statement must have its own matching endif. Keep track of indentation for clarity.
Equality
Check if values are the same or different.
Size Comparison
Compare which value is larger or smaller.
Inclusive Comparison
Include the boundary value in the comparison.
Boolean Values
Work with true/false values directly.
Multiple Conditions (Else If Pattern)
Chain conditions together to handle multiple scenarios.
Range Checking
Check if a value falls within a specific range.
Flag Variables
Use boolean variables to track states across your program.
Validation Pattern
Menu Selection
Error Checking
Status Checking
Always close your if statements
Every "if" must have a matching "endif". Missing closures will cause errors.
Use meaningful variable names for flags
Names like "is_valid", "has_permission", "found" make conditions easier to read.
Avoid too many nested levels
Deep nesting makes code hard to follow. Consider breaking complex logic into simpler parts.
Test edge cases
Make sure your conditions handle boundary values correctly (like exactly 18, exactly 0, etc.).