if / then / else
Executes code based on a condition.
Syntax
if condition then ... else ...;
Description
Do NOT put a semicolon BEFORE else. Use begin..end for multiple lines. Integer division is div, remainder is mod. Equality is =, inequality is <>.
Example
Loading editor…
Expected output
Passed
When to use?
Flow branching.
Common mistakes
- ⚠️ Do not put a ; before else: writeln('Gecti') else ...