Grade 10 · Practical
Selection (if statements)
Introduction to Programming (Delphi) · about 4 min
Selection lets a program choose between paths based on a condition — the heart of decision-making in code.
Key points- `if condition then … else …` runs one branch or the other; use `begin … end` to group several statements.
- Conditions use relational operators (=, <>, <, >, <=, >=) and logical operators (and, or, not).
- Nested ifs and `case` handle multiple options; `case` is cleaner when testing one variable against many fixed values.
- Watch the boundaries: is it `>` or `>=`? Off-by-one boundary errors are a classic bug.
- Condition — a boolean expression that is True or False.
- case statement — selection against many constant values of one ordinal variable.
EXAM TIP
for "if the mark is 50 or more, display Pass" the condition is `mark >= 50` — read the wording for "or more/at least" (>=) vs "more than" (>).