← IGCSE Computer Science Paper 2

Error: wrong relational operator

Using > instead of >= (or < instead of <=) is a logic error: the boundary value, such as Age 18, is wrongly rejected. Test the boundary value, then correct the operator.

Understanding Error: wrong relational operator in IGCSE Computer Science Paper 2

What it does: Mark >= 50 is true for 50, so the boundary value passes as the rule requires. Age <= 12 is true when Age is 12, whereas Age < 12 would wrongly reject a 12-year-old. 18 or over includes 18, so use >=. With > an 18-year-old is wrongly rejected. A mark of exactly 50 should pass, but Mark > 50 rejects it. The correct operator is >=. The code is valid, so it runs. It simply gives the wrong answer at the boundary value. Test the boundary value and the value next to it. 17 should fail and 18 should pass.

Common mistakes: Using > instead of >= wrongly rejects someone aged exactly 18, the boundary value. It should be IF Age >= 18 THEN. A mark of exactly 50 should pass, but > rejects it. Testing the boundary value 50 shows the error. It should be IF Mark >= 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 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.

Learning
Duo
A cinema lets in anyone aged 18 or over. Which condition is correct?
IF Age > 18 THENIF Age >= 18 THEN
Matches
IF Score < 40 THEN OUTPUT "Fail" ENDIF (Rule: 40 or less fails)
↓
< should be <=. A Score of exactly 40 is wrongly missed, because 40 < 40 is false. Test with the boundary value 40 and correct the operator to <=.
Applying
Meanings
Term
Age >= 18
Meaning
Using > instead of >= (or < instead of <=) is a logic error: the boundary value, such as Age 18, is wrongly rejected. Test the boundary value, then correct the operator.
Practice
// Age 18 is the boundary value
Testing
Gaps
IF Age 18 THEN
Check Answer
Spots
1INPUT Age
2IF Age > 18 THEN

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

The 'Cosmic Dragon' badge — Orbit Master, 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. A cinema lets in anyone aged 18 or over. Which condition is correct?
A. IF Age > 18 THEN
B. IF Age >= 18 THEN ✓
18 or over includes 18, so use >=. With > an 18-year-old is wrongly rejected.
2. The algorithm uses IF Age > 18 THEN to allow adults in. Which input value shows the error?
A. Age = 18, the boundary value ✓
B. Age = 40, a typical value
Errors with > and >= only appear at the boundary. 40 gives the correct result either way, but 18 is wrongly rejected.
3. A pass mark is 50 or more. Which line has a logic error?
A. IF Mark > 50 THEN ✓
B. IF Mark >= 50 THEN
A mark of exactly 50 should pass, but Mark > 50 rejects it. The correct operator is >=.
4. A bus fare discount is for people aged 16 or under. Which condition is correct?
A. IF Age <= 16 THEN ✓
B. IF Age < 16 THEN
16 or under includes 16, so use <=. With < a 16-year-old is wrongly refused the discount.
5. Which statement about the error Age > 18 instead of Age >= 18 is true?
A. It is a syntax error: the program will not run
B. It is a logic error: the program runs but gives the wrong result for 18 ✓
The code is valid, so it runs. It simply gives the wrong answer at the boundary value.

Match the Pairs

IF Age > 18 THEN → Wrong at the boundary: a person aged exactly 18 is rejected, even though the rule says 18 or over should be accepted.
IF Age >= 18 THEN → Correct operator for 'aged 18 or over': the boundary value 18 is accepted as well as everything above it.
To test a rule 'a pass mark is 50 or more', the boundary value 50 must be accepted, so use the operator that includes it. → IF Mark >= 50 THEN
A rule says 'a child ticket is for ages up to and including 12'. The boundary value 12 must be included, so the operator needs an equals part. → IF Age <= 12 THEN
IF Score < 40 THEN OUTPUT "Fail" ENDIF (Rule: 40 or less fails) → < should be <=. A Score of exactly 40 is wrongly missed, because 40 < 40 is false. Test with the boundary value 40 and correct the operator to <=.
IF Age > 18 THEN OUTPUT "Can vote" ENDIF (Rule: 18 or over can vote) → > should be >=. A person aged exactly 18 is wrongly rejected, because 18 > 18 is false. Test with the boundary value 18 and correct the operator to >=.

Key Term

Age >= 18
Using > instead of >= (or < instead of <=) is a logic error: the boundary value, such as Age 18, is wrongly rejected. Test the boundary value, then correct the operator.

Fill in the Blanks

1. IF Age >= 18 THEN OUTPUT "Adult" ENDIF
Hint: Type the relational operator that accepts an age of exactly 18 as well as older ages.
2. IF Temp <= 0 THEN OUTPUT "Freezing: 0 counts" ENDIF
Hint: Type the relational operator meaning less than or equal to, so the boundary value 0 is included.
3. // Adults are 18 or over IF Age >= 18 THEN OUTPUT "Adult"
Hint: Type the boundary value that is tested in the condition for being an adult.
4. Count ← 1 WHILE Count <= 10 DO Count ← Count + 1
Hint: Type the operator that lets the loop run when Count is equal to its last value.
5. IF Mark < 40 THEN OUTPUT "Fail: 40 is a pass" ENDIF
Hint: Type the operator that rejects only marks strictly below the boundary, because the boundary value passes.

Spot the Error

Question 1
A INPUT Age
B IF Age > 18 THEN
C OUTPUT "Can vote"
D ENDIF
Line B — Using > instead of >= wrongly rejects someone aged exactly 18, the boundary value. It should be IF Age >= 18 THEN.
Question 2
A DECLARE Mark : INTEGER
B OUTPUT "Enter mark"
C INPUT Mark
D IF Mark > 50 THEN
E OUTPUT "Pass"
F ENDIF
Line D — A mark of exactly 50 should pass, but > rejects it. Testing the boundary value 50 shows the error. It should be IF Mark >= 50 THEN.
Question 3
A IF Age < 12 THEN
B Fare ← 5
C ENDIF
Line A — A 12 year old should get the child fare, but < excludes the boundary value 12. It should be IF Age <= 12 THEN.
Question 4
A Count ← 0
B INPUT Score
C // 80 or more earns a merit
D IF Score > 80 THEN
E Count ← Count + 1
F ENDIF
Line D — A score of exactly 80 earns a merit, but > does not count it. The operator should be >=, so it should be IF Score >= 80 THEN.
Question 5
A IF Temp > 30 THEN
B OUTPUT "Hot day"
C ENDIF
Line A — A temperature of exactly 30 should count as a hot day. With > the boundary value 30 is missed. It should be IF Temp >= 30 THEN.

Student with a class code? Join your class →