Error: wrong data type or undeclared variable
An error caused by using a value its data type does not allow (e.g. a STRING stored in an INTEGER, or an index outside the array) or by using a variable that was never DECLAREd.
Understanding Error: wrong data type or undeclared variable in IGCSE Computer Science Paper 2
What it does: The array only has elements 1 to 5, so Scores[6] is outside the bounds and is not allowed. DECLARE sets the data type first (STRING), and the value stored then matches that type, so there is no error. The array has indexes 1 to 5 only. Index 6 does not exist, so Marks[6] is an error. The mistake is a missing DECLARE. Changing the assignment symbol does not declare the variable. REAL stores numbers with decimals. The STRING "free" cannot be stored in a REAL variable. Age was declared as INTEGER, so it can only hold whole numbers. Storing the text "twelve" in it breaks the data type rule.
Common mistakes: Age is declared as INTEGER, so it cannot store the STRING "fifteen". It should be Age ← 15. Score is used for arithmetic and is given the number 0, so it must be an INTEGER. Declaring it as STRING makes these lines data type errors.
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 242–253) 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.
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
Data type errorFill in the Blanks
Spot the Error
Student with a class code? Join your class →