Nested if blocks in pseudocode
An if block written inside another if block. The inner condition is only checked when the outer condition is true. Indent the inner block and give each if its own end if.
Understanding Nested if blocks in pseudocode in Years 7–8 Creating Digital Solutions
What it does: Indenting each inner block shows it is inside the block above it, which makes the algorithm easier to read and trace. The print only runs when raining is true and haveUmbrella is true, which matches: if raining = true AND haveUmbrella = true then. Every if needs its own end if. The inner end if closes the inner block and the outer end if closes the outer block. 40 is not >= 50, so the outer condition is false. The computer never looks at the inner condition. Nesting lets you run extra steps after the outer check passes and add a separate else for the inner check. AND combines the checks into one.
Common mistakes: The inner if is missing the keyword then. It should be: if has_ticket = true then. The inner if ends with the wrong word. The keyword is then, not than. It should be: if score >= 90 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 3–47) and word search (Modules 3–125).
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
nested ifFill in the Blanks
Spot the Error
Student with a class code? Join your class →