Choosing between INTEGER and REAL
Use INTEGER for values that are always whole numbers, like a count of students. Use REAL if the value could have a decimal part, like a price or an average mark.
Understanding Choosing between INTEGER and REAL in IGCSE Computer Science Paper 2
What it does: Prices like 4.99 have a fractional part, so the variable must be declared as REAL. Seats are counted in whole units, so INTEGER is the suitable data type. A count of students is always a whole number. You cannot have 2.5 students, so INTEGER is the right choice. An average often comes out as a decimal, such as 72.5, even if every mark was whole. Use REAL. If the value could later need decimals, like a price changing to 5.50, choose REAL from the start. Choose by what the value could become, not just its current value.
Common mistakes: items is an INTEGER, so it can only hold whole numbers. 12.5 has a decimal part. The line should be items ← 12. A number of students is always a whole number, so it should be declared as INTEGER, not REAL.
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 327–336) 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
INTEGER or REALFill in the Blanks
Spot the Error
Student with a class code? Join your class →