← IGCSE Computer Science Paper 2

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

Gives the statements that run when the IF condition is FALSE. ELSE has no condition of its own, so exactly one of the two branches (THEN or ELSE) runs.

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

What it does: The OR condition catches values below 0 or above 100 in the THEN branch. Every other value goes to the ELSE branch, so Correct becomes TRUE. ELSE has no condition of its own. It simply runs when the IF condition is FALSE. The whole IF statement must be closed with ENDIF, even when it has an ELSE. Assignment uses ←. The = sign is for comparison, so it is wrong here.

Common mistakes: Assignment in pseudocode uses the ← arrow. The = sign is used to compare values. It should be Correct ← FALSE. No number is both below 0 and above 100, so AND is always FALSE and the ELSE branch would always run. The condition needs OR.

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 line is correct pseudocode for the ELSE part of an IF statement?
ELSE Answer >= 0 THENELSE
Matches
IF Score > 10 THEN OUTPUT "High" ELSE Score <= 10 THEN OUTPUT "Low" ENDIF
↓
ELSE has been given a condition and THEN. ELSE never has a condition, so it should just be ELSE on its own line.
Applying
Meanings
Term
ELSE
Meaning
Gives the statements that run when the IF condition is FALSE. ELSE has no condition of its own, so exactly one of the two branches (THEN or ELSE) runs.
Practice
IF Answer < 0 OR Answer > 100
Testing
Gaps
Check Answer
Spots
2 THEN
3 Correct = FALSE

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

The 'Warthog' badge — Definition Digger, 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 line is correct pseudocode for the ELSE part of an IF statement?
A. ELSE ✓
B. ELSE Answer >= 0 THEN
ELSE has no condition of its own. It simply runs when the IF condition is FALSE.
2. When the condition after IF is FALSE, what happens?
A. The statements after THEN run
B. The statements after ELSE run ✓
THEN runs when the condition is TRUE. ELSE runs when it is FALSE.
3. In an IF ... THEN ... ELSE ... ENDIF statement, how many branches run each time?
A. Both, one after the other
B. Exactly one ✓
Either the THEN branch or the ELSE branch runs, never both.
4. Answer is 150. IF Answer < 0 OR Answer > 100 THEN Correct ← FALSE ELSE Correct ← TRUE ENDIF. What is Correct?
A. FALSE ✓
B. TRUE
150 > 100 makes the condition TRUE, so the THEN branch runs and Correct ← FALSE.
5. Answer is 50. IF Answer < 0 OR Answer > 100 THEN Correct ← FALSE ELSE Correct ← TRUE ENDIF. What is Correct?
A. TRUE ✓
B. FALSE
50 is not below 0 and not above 100, so the condition is FALSE. The ELSE branch runs and Correct ← TRUE.

Match the Pairs

IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF → Exactly one message is output: Pass when Mark is 50 or more, otherwise Fail
ELSE → Starts the statements that run when the IF condition is FALSE; it has no condition of its own
Check a range: set Correct to FALSE if Answer is outside 0 to 100, otherwise set it to TRUE → IF Answer < 0 OR Answer > 100 THEN Correct ← FALSE ELSE Correct ← TRUE ENDIF
ELSE has no condition, so it is written on its own line with nothing after it → IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child" ENDIF
IF Score > 10 THEN OUTPUT "High" ELSE Score <= 10 THEN OUTPUT "Low" ENDIF → ELSE has been given a condition and THEN. ELSE never has a condition, so it should just be ELSE on its own line.
IF Answer < 0 OR Answer > 100 THEN Correct ← FALSE ELSE Correct ← TRUE → The ENDIF is missing, so the IF ... ELSE structure is never closed. ENDIF must be added after the ELSE branch.

Key Term

ELSE
Gives the statements that run when the IF condition is FALSE. ELSE has no condition of its own, so exactly one of the two branches (THEN or ELSE) runs.

Fill in the Blanks

1. Correct ← FALSE ELSE Correct ← TRUE
Hint: Type the keyword that starts the branch that runs when the IF condition is FALSE.
2. IF Answer < 0 OR Answer > 100 THEN Correct ← FALSE
Hint: Type the logical operator that is TRUE when either out-of-range test is TRUE.
3. ELSE Correct ← TRUE ENDIF
Hint: Type the Boolean value stored when the answer is in range, so the condition was FALSE.
4. THEN Correct ← FALSE ELSE
Hint: Type the Boolean value stored when the answer is out of range and the THEN branch runs.
5. ELSE OUTPUT "Well done" ENDIF
Hint: Type the keyword that closes the whole IF statement after the ELSE branch.

Spot the Error

Question 1
A IF Answer < 0 OR Answer > 100
B THEN
C Correct = FALSE
D ELSE
E Correct ← TRUE
F ENDIF
Line C — Assignment in pseudocode uses the ← arrow. The = sign is used to compare values. It should be Correct ← FALSE.
Question 2
A INPUT Answer
B IF Answer < 0 AND Answer > 100
C THEN Correct ← FALSE
D ELSE Correct ← TRUE
E ENDIF
Line B — No number is both below 0 and above 100, so AND is always FALSE and the ELSE branch would always run. The condition needs OR.
Question 3
A IF Mark >= 50
B THEN
C Result ← "Pass"
D ELSE Mark < 50
E Result ← "Fail"
F ENDIF
Line D — ELSE has no condition. It simply runs when the IF condition is FALSE. The line should be just ELSE.
Question 4
A INPUT Number
B IF Number MOD 2 ← 0
C THEN OUTPUT "Even"
D ELSE OUTPUT "Odd"
E ENDIF
Line B — The IF condition compares values, so it needs the comparison operator = and not the assignment arrow ←. It should be IF Number MOD 2 = 0.
Question 5
A IF Answer < 0 OR > 100
B THEN
C Correct ← FALSE
D ELSE
E Correct ← TRUE
F ENDIF
Line A — Each side of OR must be a complete condition. Answer must be repeated: IF Answer < 0 OR Answer > 100.

Student with a class code? Join your class →