← IGCSE Computer Science Paper 2

IF ... THEN ... ENDIF (7c)

Runs the statements between THEN and ENDIF only when the condition is TRUE. If it is FALSE, they are skipped. Every IF must be closed with ENDIF, e.g. IF Score > 50 THEN OUTPUT "Pass" ENDIF.

Understanding IF ... THEN ... ENDIF (7c) in IGCSE Computer Science Paper 2

What it does: OUTPUT "Can apply" only runs when Age >= 16 is TRUE. If Age is 15 it is skipped and the program carries on after ENDIF. The IF line is matched by an ENDIF at the end, so the structure is complete and correct. Every IF must be closed with ENDIF. Without it the statement is incomplete. 40 > 50 is FALSE, so the statements between THEN and ENDIF are skipped. > means strictly greater than. 50 is not greater than 50, so the condition is FALSE. An IF statement uses THEN after the condition. DO belongs to WHILE loops. The IF line should read IF Score > 50 THEN. THEN separates the condition from the statements that run when it is TRUE.

Common mistakes: Text to be displayed must be written as a string literal in double quotes. Without quotes, Pass looks like a variable. It should be OUTPUT "Pass". The condition must be followed by THEN, which introduces the statements that run when the condition is TRUE. It should be IF Score > 50 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 156–165) and word search (Modules 146–165).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which is the correct way to write a simple IF statement in IGCSE pseudocode?
IF Score > 50 THEN OUTPUT "Pass" ENDIFIF Score > 50 THEN OUTPUT "Pass"
Matches
IF Score > 50 THEN OUTPUT "Pass"
↓
The ENDIF is missing, so the IF statement is never closed and it is unclear where the IF ends
Applying
Meanings
Term
IF ... THEN ... ENDIF
Meaning
Runs the statements between THEN and ENDIF only when the condition is TRUE. If it is FALSE, they are skipped. Every IF must be closed with ENDIF, e.g. IF Score > 50 THEN OUTPUT "Pass" ENDIF.
Practice
INPUT Score
Testing
Gaps
Score > 50 THEN
Check Answer
Spots
2IF Score > 50 THEN
3 OUTPUT Pass

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

The 'Meerkat' badge — Communicator, 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 is the correct way to write a simple IF statement in IGCSE pseudocode?
A. IF Score > 50 THEN OUTPUT "Pass" ENDIF ✓
B. IF Score > 50 THEN OUTPUT "Pass"
Every IF must be closed with ENDIF. Without it the statement is incomplete.
2. Score is 40. The code is: IF Score > 50 THEN OUTPUT "Pass" ENDIF. What happens?
A. Nothing is output, because the statements are skipped ✓
B. "Pass" is output
40 > 50 is FALSE, so the statements between THEN and ENDIF are skipped.
3. Score is 70. The code is: IF Score > 50 THEN OUTPUT "Pass" ENDIF. What happens?
A. "Pass" is output ✓
B. Nothing is output
70 > 50 is TRUE, so the statements between THEN and ENDIF run.
4. When do the statements between THEN and ENDIF run?
A. Every time the program runs
B. Only when the condition is TRUE ✓
The condition decides. If it is FALSE, the statements are skipped.
5. What does the keyword ENDIF do?
A. Stops the whole program
B. Marks the end of the IF statement ✓
ENDIF only closes the IF. The program carries on with the next line after it.

Match the Pairs

IF Score > 50 THEN OUTPUT "Pass" ENDIF → Outputs Pass only when Score is greater than 50; otherwise nothing happens
ENDIF → Closes an IF statement and marks where the statements that depend on the condition end
The statements between THEN and ENDIF run only when the condition is TRUE → IF Age >= 16 THEN OUTPUT "Can apply" ENDIF
Every IF statement must be closed with its own ENDIF → IF Temp < 0 THEN OUTPUT "Ice" ENDIF
IF Score > 50 THEN OUTPUT "Pass" → The ENDIF is missing, so the IF statement is never closed and it is unclear where the IF ends
IF Score > 50 OUTPUT "Pass" ENDIF → THEN is missing after the condition, so the IF line is incomplete

Key Term

IF ... THEN ... ENDIF
Runs the statements between THEN and ENDIF only when the condition is TRUE. If it is FALSE, they are skipped. Every IF must be closed with ENDIF, e.g. IF Score > 50 THEN OUTPUT "Pass" ENDIF.

Fill in the Blanks

1. IF Score > 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the keyword that starts a selection statement and introduces the condition.
2. IF Score > 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the keyword that comes after the condition and begins the statements that run when it is TRUE.
3. IF Score > 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the keyword that closes every selection statement of this kind.
4. IF Score > 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the relational operator that checks whether Score is greater than the number.
5. IF Score > 50 THEN OUTPUT "Pass" ENDIF
Hint: Type the keyword that displays a message, run only when the condition is TRUE.

Spot the Error

Question 1
A INPUT Score
B IF Score > 50 THEN
C OUTPUT Pass
D ENDIF
Line C — Text to be displayed must be written as a string literal in double quotes. Without quotes, Pass looks like a variable. It should be OUTPUT "Pass".
Question 2
A IF Score > 50
B OUTPUT "Pass"
C ENDIF
Line A — The condition must be followed by THEN, which introduces the statements that run when the condition is TRUE. It should be IF Score > 50 THEN.
Question 3
A IF Mark >= 40 THEN
B OUTPUT "Pass"
C ENDWHILE
D OUTPUT "Done"
Line C — An IF statement must be closed with ENDIF. ENDWHILE closes a WHILE loop, not an IF. The line should be ENDIF.
Question 4
A INPUT Temp
B OUTPUT "Checking"
C IF Temp ← 30 THEN
D OUTPUT "Hot"
E ENDIF
Line C — A condition needs a relational operator to compare values. The arrow ← is assignment, not a comparison. It should be IF Temp > 30 THEN.
Question 5
A INPUT Score
B IF Score > 50 THEN
C OUTPUT "Fail"
D ENDIF
Line B — The wrong relational operator makes the condition TRUE for high scores, so "Fail" would be output for students who passed. It should be IF Score < 50 THEN.

Student with a class code? Join your class →