← ACARA Digital Technologies Years 5–6

A decision inside a decision

A second IF written inside the THEN or ELSE path of the first IF. It is only checked when that path is taken. Indent it and give each IF its own END IF.

Understanding A decision inside a decision in ACARA Digital Technologies Years 5–6

What it does: The inner END IF closes the key check and the outer END IF closes the coins check, so both IFs are closed. The level = 2 check sits inside ELSE, so it only happens when level is not 1. A nested IF sits inside another IF's path. It is a decision inside a decision. The inner IF is inside the THEN path. If score > 10 is false, the computer skips the whole path, so the inner IF is never checked. Indenting shows which IF is inside which. Every IF needs its own END IF. Each IF has its own END IF. Two IFs means two END IFs.

Common mistakes: The step inside the inner IF is missing the word TO. It should be ' SET bonus TO 10'. This step only runs when both IFs are true. The inner IF is missing THEN. Every IF needs THEN after its condition: ' IF door = open 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 85–104) and word search (Modules 73–104).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which describes a nested IF?
Two IFs written one after the other with nothing inside themA second IF written inside the THEN or ELSE path of the first IF
Matches
IF score > 50 THEN IF lives > 0 THEN SAY "Next level" END IF
↓
The outer IF has no END IF. Each IF needs its own END IF, so this needs a second END IF at the end.
Applying
Meanings
Term
nested IF
Meaning
A second IF written inside the THEN or ELSE path of the first IF. It is only checked when that path is taken. Indent it and give each IF its own END IF.
Practice
IF score >= 50 THEN
Testing
Gaps
lives > 0 THEN
Check Answer
Spots
3 IF score > 50 THEN
4 SET bonus 10

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

The 'Cheetah' badge — Savannah Sprinter, 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. Which describes a nested IF?
A. Two IFs written one after the other with nothing inside them
B. A second IF written inside the THEN or ELSE path of the first IF ✓
A nested IF sits inside another IF's path. It is a decision inside a decision.
2. In this algorithm, when is the inner IF checked? IF score > 10 THEN IF score > 50 THEN say "Wow!" END IF END IF
A. Only when score > 10 is true ✓
B. Every time, even when score is 3
The inner IF is inside the THEN path. If score > 10 is false, the computer skips the whole path, so the inner IF is never checked.
3. Which nested IF is laid out correctly?
A. The inner IF is indented, and each IF has its own END IF ✓
B. The inner IF is not indented, and one END IF closes both IFs
Indenting shows which IF is inside which. Every IF needs its own END IF.
4. A game has two IFs, one inside the other. How many END IF lines does it need?
A. 2 END IF lines, one for each IF ✓
B. 1 END IF line, because the IFs are joined
Each IF has its own END IF. Two IFs means two END IFs.
5. Game level example: IF level = 1 THEN IF lives = 0 THEN say "Game over" END IF END IF If level is 2, what happens to the inner IF?
A. It is checked and says Game over
B. It is skipped and never checked ✓
level = 1 is false, so the THEN path is not taken. The inner IF about lives is never checked.

Match the Pairs

IF score > 50 THEN IF lives > 0 THEN SAY "Next level" END IF END IF → A nested IF: the inner IF about lives is only checked when the score is over 50.
IF lives > 0 THEN → The inner IF is indented to show it belongs inside the outer IF's path.
Each IF needs its own END IF, so two IFs need two END IFs. → IF coins = 10 THEN IF key = 1 THEN SAY "Door opens" END IF END IF
An IF inside the ELSE path is only checked when the first condition is false. → IF level = 1 THEN SAY "Easy mode" ELSE IF level = 2 THEN SAY "Medium mode" END IF END IF
IF score > 50 THEN IF lives > 0 THEN SAY "Next level" END IF → The outer IF has no END IF. Each IF needs its own END IF, so this needs a second END IF at the end.
IF score > 50 THEN IF lives > 0 THEN SAY "Next level" END IF END IF → The inner IF is not indented, so it is hard to see that it is inside the first IF's THEN path.

Key Term

nested IF
A second IF written inside the THEN or ELSE path of the first IF. It is only checked when that path is taken. Indent it and give each IF its own END IF.

Fill in the Blanks

1. IF score >= 50 THEN IF lives > 0 THEN SAY "Go to level 2"
Hint: Type the keyword that starts the second decision inside the first path.
2. IF coins > 10 THEN IF key = "yes" THEN SAY "Door opens"
Hint: Type the keyword that comes after the inner condition and begins the path it controls.
3. SAY "Door opens" END IF END IF
Hint: Type the two words that close the inner decision, which is indented, before the outer one closes.
4. ELSE IF lives > 0 THEN SAY "Try again"
Hint: Type the operator that checks the player has more than zero lives left.
5. IF level = 3 THEN IF boss_beaten = "yes" THEN SAY "You win!"
Hint: Type the operator that checks whether the level is exactly equal to a number.

Spot the Error

Question 1
A IF lives > 0 THEN
B SET bonus TO 0
C IF score > 50 THEN
D SET bonus 10
E END IF
F END IF
Line D — The step inside the inner IF is missing the word TO. It should be ' SET bonus TO 10'. This step only runs when both IFs are true.
Question 2
A IF key = 1 THEN
B IF door = open
C SAY You win
D END IF
E END IF
Line B — The inner IF is missing THEN. Every IF needs THEN after its condition: ' IF door = open THEN'.
Question 3
A score >= 100 THEN
B IF lives > 0 THEN
C SET level TO 2
D END IF
E END IF
Line A — The outer decision must start with the word IF. It should be 'IF score >= 100 THEN'.
Question 4
A IF hasMap = YES THEN
B IF hasKey YES THEN
C SAY Open the chest
D END IF
E END IF
Line B — The inner condition is missing the = sign, so it does not compare anything. It should be ' IF hasKey = YES THEN'.
Question 5
A IF lives < 0 THEN
B IF score > 50 THEN
C SAY Bonus level
D END IF
E END IF
Line A — Lives are never below 0 while playing, so the THEN path is never taken and the inner IF is never checked. It should be 'IF lives > 0 THEN'.

Student with a class code? Join your class →