← IGCSE Computer Science Paper 2

Relational operators: = and <>

= tests whether two values are equal and <> tests whether they are not equal. Each gives TRUE or FALSE. Assignment uses <- instead, not =.

Understanding Relational operators: = and <> in IGCSE Computer Science Paper 2

What it does: Assignment uses the arrow <- to store 5 in Answer, whereas = would only test for equality. = compares two values in a condition, and text values are written in double quotes. The result is TRUE or FALSE, which IF uses to decide. <> means 'is not equal to'. "Alex" is not the same as "Sam", so the test gives TRUE. Answer is equal to 5, so 'not equal to 5' is FALSE. Cambridge pseudocode writes not equal as <>. The != symbol is used in languages such as Python and JavaScript. In a condition, = only compares. It never changes the value of Score. To change Score you would use Score <- 10.

Common mistakes: <- is assignment, not a test. A condition must use = to compare Answer with 5. It should be IF Answer = 5 THEN. Cambridge pseudocode uses <> for 'not equal to', not !=. It should be IF Name <> "Sam" 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 358–368) and word search (Modules 358–378).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which condition checks whether Answer is equal to 5 in Cambridge pseudocode?
IF Answer <- 5 THENIF Answer = 5 THEN
Matches
IF Score <- 10 THEN
↓
<- is assignment, not a comparison. A condition should use = to test equality: IF Score = 10 THEN
Applying
Meanings
Term
= and <>
Meaning
= tests whether two values are equal and <> tests whether they are not equal. Each gives TRUE or FALSE. Assignment uses <- instead, not =.
Practice
Answer ← 5
Testing
Gaps
IF Answer 5 THEN
Check Answer
Spots
3OUTPUT "Guess the number"
4IF Answer <- 5 THEN

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

The 'Barreleye Fish' badge — Clear Vision, 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 condition checks whether Answer is equal to 5 in Cambridge pseudocode?
A. IF Answer <- 5 THEN
B. IF Answer = 5 THEN ✓
In a condition, = compares two values. <- is only used for assignment, so it does not belong in an IF test.
2. Which line stores the value 5 in the variable Answer?
A. Answer = 5
B. Answer <- 5 ✓
Assignment uses <- in Cambridge pseudocode. Writing Answer = 5 is a comparison that gives TRUE or FALSE, and it does not store anything.
3. Name has the value "Alex". What does Name <> "Sam" give?
A. TRUE ✓
B. FALSE
<> means 'is not equal to'. "Alex" is not the same as "Sam", so the test gives TRUE.
4. Answer has the value 5. What does Answer <> 5 give?
A. FALSE ✓
B. TRUE
Answer is equal to 5, so 'not equal to 5' is FALSE.
5. Which symbol means 'is not equal to' in Cambridge pseudocode?
A. <> ✓
B. !=
Cambridge pseudocode writes not equal as <>. The != symbol is used in languages such as Python and JavaScript.

Match the Pairs

Answer = 5 → Tests whether Answer is equal to 5 and gives TRUE or FALSE
Name <> "Sam" → Tests whether Name is not equal to the text "Sam" and gives TRUE if it is different
Use <- (not =) when you want to store a value in a variable → Answer <- 5
Use = inside an IF condition to check whether text matches exactly → IF Colour = "red" THEN
IF Score <- 10 THEN → <- is assignment, not a comparison. A condition should use = to test equality: IF Score = 10 THEN
IF Age != 18 THEN → Cambridge pseudocode uses <> for not equal, not !=. It should be IF Age <> 18 THEN

Key Term

= and <>
= tests whether two values are equal and <> tests whether they are not equal. Each gives TRUE or FALSE. Assignment uses <- instead, not =.

Fill in the Blanks

1. IF Answer = 5 THEN OUTPUT "Correct" ENDIF
Hint: Type the relational operator that tests whether two values are equal.
2. IF Name <> "Sam" THEN OUTPUT "Not Sam" ENDIF
Hint: Type the operator that tests whether two values are NOT equal.
3. Answer <- 5
Hint: This line stores a value in a variable. Type the assignment operator, not the equality test.
4. IF Pet = "cat" THEN OUTPUT "Meow" ENDIF
Hint: Type the operator that checks whether the text in the variable is the same as the text shown.
5. WHILE Guess <> Answer DO INPUT Guess ENDWHILE
Hint: The loop should keep running while the two values are different. Type the operator for that.

Spot the Error

Question 1
A DECLARE Answer : INTEGER
B Answer <- 5
C OUTPUT "Guess the number"
D IF Answer <- 5 THEN
E OUTPUT "Correct"
F ENDIF
Line D — <- is assignment, not a test. A condition must use = to compare Answer with 5. It should be IF Answer = 5 THEN.
Question 2
A DECLARE Name : STRING
B INPUT Name
C OUTPUT "Checking name"
D IF Name != "Sam" THEN
E OUTPUT "Not Sam"
F ENDIF
Line D — Cambridge pseudocode uses <> for 'not equal to', not !=. It should be IF Name <> "Sam" THEN.
Question 3
A INPUT Answer
B IF Answer == 5 THEN
C OUTPUT "Correct"
D ENDIF
Line B — Pseudocode uses a single = to test whether two values are equal. == belongs to other languages. It should be IF Answer = 5 THEN.
Question 4
A INPUT Name
B IF Name <> Sam THEN
C OUTPUT "Access denied"
D ENDIF
Line B — Text values must be in double quotes. Without them, Sam looks like a variable name. It should be IF Name <> "Sam" THEN.
Question 5
A DECLARE Answer : INTEGER
B Answer <- 0
C WHILE Answer = 5 DO
D INPUT Answer
E ENDWHILE
Line C — The loop should keep asking while the answer is NOT 5. With = the condition is FALSE at the start, so the loop never runs. It should be WHILE Answer <> 5 DO.

Student with a class code? Join your class →