Choosing nested IFs or one compound condition
IF A AND B gives the same result as IF A THEN IF B when one action needs both tests. Use nesting when each test needs its own different ELSE outcome.
Understanding Choosing nested IFs or one compound condition in ACARA Digital Technologies Years 9–10
What it does: The action only runs when A and B are both true, so both versions give the same result. Each ELSE tells the user which test failed. A single AND condition has only one ELSE, so it cannot do this. When the tests share one action, the compound condition is shorter and easier to read. It also avoids extra ENDIFs and indentation. The two failures need different messages. Nesting lets each IF have its own ELSE, so the right message appears for the right reason. There are three different outcomes. The inner IF needs its own ELSE, so the tests must be nested.
Common mistakes: Both tests must be true for a teen ticket, so the tests need AND. With OR, every age passes at least one test. It should be IF age > 12 AND age < 18 THEN. An IF with a compound condition still needs THEN at the end of the line. It should be IF paid AND age < 18 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 492–534) and word search (Modules 459–534).
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 IF vs ANDFill in the Blanks
Spot the Error
Student with a class code? Join your class →