Assigned value must match the variable's data type
An error when a value assigned to a variable has a different data type from the one it was declared with, such as storing a name in an INTEGER variable.
Understanding Assigned value must match the variable's data type in IGCSE Computer Science Paper 2
What it does: STRING values are written in double quotes, so "Ali" matches the STRING variable Name. Age was declared as INTEGER, so it can only hold whole numbers. "Ali" is a STRING, which causes a type mismatch. 42 is an INTEGER literal and the variable is declared as INTEGER, so the types match. A CHAR holds exactly one character in single quotes. "Ali" is a STRING, so the types do not match.
Common mistakes: Age was declared as INTEGER, so it can only hold whole numbers. The text "Ali" is a STRING, which causes a type mismatch. It should be a whole number such as Age ← Age + 1. Name is assigned the text "Ali", so it must be declared as STRING. An INTEGER variable cannot hold text. It should be DECLARE Name : STRING.
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 317–326) and word search (Modules 317–336).
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
type mismatchFill in the Blanks
Spot the Error
Student with a class code? Join your class →