Error: missing ENDIF, NEXT, ENDWHILE or UNTIL
Closing keywords that end IF, FOR, WHILE and REPEAT. Each one must match its opening statement. A missing or mismatched closing keyword is an error.
Understanding Error: missing ENDIF, NEXT, ENDWHILE or UNTIL in IGCSE Computer Science Paper 2
What it does: REPEAT is closed by UNTIL followed by the condition. ENDWHILE only belongs to WHILE loops. Each IF is closed by its own ENDIF. The inner ENDIF closes the inner IF and the outer ENDIF closes the outer IF. The identifier after NEXT must be the same as the loop variable in the FOR line. NEXT Counter is a different identifier, so it is an error. Each IF needs its own ENDIF. A nested IF with only one ENDIF has a missing closing keyword. ENDIF is required. Without it the algorithm is incorrect because the end of the IF statement is not shown.
Common mistakes: The loop counter is now Num, but the loop is closed with NEXT Count. NEXT must use the same identifier as the FOR line. The first line should be FOR Count ← 1 TO 5. A WHILE loop must be closed with ENDWHILE. ENDIF closes an IF statement, so it is the wrong closing keyword here.
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 232–241) and word search (Modules 232–253).
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
ENDIF NEXT ENDWHILE UNTILFill in the Blanks
Spot the Error
Student with a class code? Join your class →