← QCE Digital Solutions Unit 1

if-then-else block

A selection structure that runs one set of instructions if a condition is true, and a different set if it is false

Understanding if-then-else block in QCE Digital Solutions Unit 1

What it does: END IF is the keyword pair that marks the end of a selection block. This description matches the IF-THEN-ELSE selection structure. IF-THEN-ELSE runs one set of instructions if the condition is true, and another if it is false. A simple IF-THEN block without ELSE is valid when there's no alternative action needed. The closing keyword is written as two words: END IF. ENDIF written as one word is incorrect — VCAA pseudocode uses END IF as two words.

Common mistakes: The block should close with END IF, not END OF IF. The condition line is missing THEN — it should read IF total > 100 THEN.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 158–380) and word search (Modules 82–380).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does an IF-THEN-ELSE block let an algorithm choose between two paths?
TrueFalse
Matches
IF total > 100 DISPLAY "Over" ELSE DISPLAY "OK" ENDIF
↓
The closing keyword should be written as END IF, not ENDIF
Applying
Meanings
Term
IF-THEN-ELSE
Meaning
A selection structure that runs one set of instructions if a condition is true, and a different set if it is false
Practice
BEGIN
Testing
Gaps
IF x > 0
Check Answer
Spots
4 DISPLAY "Minor"
5END OF IF

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Reindeer' badge — Dictionary Guide, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does an IF-THEN-ELSE block let an algorithm choose between two paths?
A. True ✓
B. False
IF-THEN-ELSE runs one set of instructions if the condition is true, and another if it is false.
2. Which keyword introduces the instructions run when the condition is false?
A. THEN
B. ELSE ✓
ELSE introduces the branch that runs when the condition evaluates to false.
3. Which keyword must follow the condition in an IF statement?
A. THEN ✓
B. DO
THEN follows the condition and introduces the true branch of the block.
4. Should an IF-THEN-ELSE block be closed with END IF?
A. No
B. Yes ✓
END IF marks the end of the selection block in VCAA pseudocode.
5. Can an IF-THEN-ELSE block be written without an ELSE branch at all?
A. Yes, using IF-THEN alone ✓
B. No, ELSE is always required
A simple IF-THEN block without ELSE is valid when there's no alternative action needed.

Match the Pairs

IF score >= 50 THEN → Starts a selection block and introduces the true branch
ELSE → Introduces the instructions run when the condition is false
A keyword that closes an IF-THEN-ELSE block → END IF
A structure that runs different instructions depending on a condition → IF-THEN-ELSE block
IF total > 100 DISPLAY "Over" ELSE DISPLAY "OK" ENDIF → The closing keyword should be written as END IF, not ENDIF
IF stock = 0 DISPLAY "Out" ELSE DISPLAY "In" END IF → The condition line is missing THEN after the condition

Key Term

IF-THEN-ELSE
A selection structure that runs one set of instructions if a condition is true, and a different set if it is false

Fill in the Blanks

1. IF x > 0 THEN
Hint: Type the keyword that follows a condition
2. IF x > 0 THEN DISPLAY "Positive" ELSE
Hint: Type the keyword that introduces the false branch
3. IF p THEN DISPLAY p END IF
Hint: Type the keywords that close the selection block
4. IF a = b THEN
Hint: Type the keyword that starts a selection block
5. IF valid THEN DISPLAY "OK" ELSE
Hint: Type the keyword that introduces the alternative branch

Spot the Error

Question 1
A IF age >= 18 THEN
B DISPLAY "Adult"
C ELSE
D DISPLAY "Minor"
E END OF IF
Line E — The block should close with END IF, not END OF IF.
Question 2
A IF total > 100
B DISPLAY "Over budget"
C ELSE
D DISPLAY "Within budget"
E END IF
Line A — The condition line is missing THEN — it should read IF total > 100 THEN.
Question 3
A IF stock = 0 THEN
B DISPLAY "Out of stock"
C OTHERWISE
D DISPLAY "In stock"
E END IF
Line C — The keyword for the false branch is ELSE, not OTHERWISE.
Question 4
A IF n < 10 THEN
B DISPLAY "Small"
C ELSE
D DISPLAY "Large"
E END
Line E — The block must close with END IF, not just END.
Question 5
A IF x = y THEN
B DISPLAY "Equal"
C ELSE IF
D DISPLAY "Not equal"
E END IF
Line C — A simple two-branch block uses ELSE alone, not ELSE IF, unless chaining a further condition.

Student with a class code? Join your class →