Closing nested structures in the right order
Each IF and each REPEAT needs its own end line. Close the innermost block first, so END IF comes before END REPEAT when an IF is inside a loop. A missing end line is an error.
Understanding Closing nested structures in the right order in ACARA Digital Technologies Years 7–8
What it does: The IF opens inside the loop and is closed by its own END IF before the loop ends with END REPEAT. Every IF has its own END IF. Each opening line is matched with exactly one end line. The IF opened last, so it is closed first. The loop is closed after it. END IF always closes an IF. END REPEAT is the line that closes the REPEAT. Each IF needs its own END IF, even when both are in the same loop. Every IF needs its own END IF. Without it, the END REPEAT cannot close the loop properly.
Common mistakes: Line 2 opens a second IF, but the outer block is closed by END REPEAT. It should be REPEAT 4 TIMES so that END REPEAT has a REPEAT to match. Line 3 opens a REPEAT, but it is closed by END IF, so the end line does not match its opening line. It should be IF n < 2 THEN.
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 365–411) and word search (Modules 331–411).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
END IF / END REPEATFill in the Blanks
Spot the Error
Student with a class code? Join your class →