← IGCSE Computer Science Paper 2

REAL data type

The data type for a number that can have a fractional part, written with a digit on each side of the point, such as 4.7 or 0.3. 5 is an INTEGER but 5.0 is REAL.

Understanding REAL data type in IGCSE Computer Science Paper 2

What it does: Count stores the whole number 5 (INTEGER), while Length stores 5.0, which has a decimal point so it is REAL. -4.0 is a REAL literal: it has a digit before and after the point, and the fractional part can be zero.

Common mistakes: A REAL literal needs at least one digit on each side of the decimal point. .7 should be written 0.7. Height stores 1.75, which has a fractional part. An INTEGER cannot hold it, so the variable must be declared as REAL.

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 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.

Learning
Duo
Which value is a REAL literal in Cambridge pseudocode?
474.7
Matches
Price ← .5
↓
A REAL must have a digit before the decimal point, so .5 is invalid. It should be 0.5.
Applying
Meanings
Term
REAL
Meaning
The data type for a number that can have a fractional part, written with a digit on each side of the point, such as 4.7 or 0.3. 5 is an INTEGER but 5.0 is REAL.
Practice
DECLARE TotalToPay : REAL
Testing
Gaps
DECLARE Price :
Check Answer
Spots
1DECLARE Price : REAL
2Price ← .7

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

The 'Roadrunner' badge — Streak Runner, 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 value is a REAL literal in Cambridge pseudocode?
A. 4.7 ✓
B. 47
4.7 has a fractional part and a digit on each side of the point, so it is REAL. 47 is a whole number, so it is INTEGER.
2. Which data type should you choose for TotalToPay, which holds 12.50 (money)?
A. INTEGER
B. REAL ✓
Money often has pence or cents, so it needs a fractional part. That makes REAL the right type.
3. Which literal is REAL?
A. 5.0 ✓
B. 5
5 is an INTEGER. Writing 5.0 with a decimal point makes it REAL, even though the fractional part is zero.
4. Which is the correct way to write a REAL value of three tenths?
A. .3
B. 0.3 ✓
A REAL must have at least one digit on each side of the decimal point, so write 0.3, not .3.
5. Which is the correct way to write a REAL value of four?
A. 4.0 ✓
B. 4.
There must be a digit after the point as well as before it, so 4.0 is valid and 4. is not.

Match the Pairs

DECLARE TotalToPay : REAL → Creates a variable that can store a number with a fractional part, such as a price
Height ← 0.3 → Assigns a REAL literal with a digit on each side of the point
5 is an INTEGER because it has no decimal point, but 5.0 is a REAL → Count ← 5 Length ← 5.0
A negative REAL still has a digit on each side of the point, even when its fractional part is zero → Temperature ← -4.0
Price ← .5 → A REAL must have a digit before the decimal point, so .5 is invalid. It should be 0.5.
TotalToPay ← 12. → A REAL must have a digit after the decimal point, so 12. is invalid. It should be 12.0.

Key Term

REAL
The data type for a number that can have a fractional part, written with a digit on each side of the point, such as 4.7 or 0.3. 5 is an INTEGER but 5.0 is REAL.

Fill in the Blanks

1. DECLARE Price : REAL Price ← 4.7
Hint: Type the data type for a number that can have a fractional part.
2. DECLARE Height : REAL Height ← 1.5
Hint: Type the keyword that creates a new variable.
3. DECLARE Distance : REAL Distance ← 5.0 // five as a REAL value
Hint: Type the REAL literal for five, with a digit after the point.
4. DECLARE TotalToPay : REAL TotalToPay ← 12.5
Hint: Type the variable name for the money the customer owes.
5. DECLARE Count : INTEGER Count ← 5
Hint: Type the data type for a whole number with no decimal point.

Spot the Error

Question 1
A DECLARE Price : REAL
B Price ← .7
C OUTPUT Price
Line B — A REAL literal needs at least one digit on each side of the decimal point. .7 should be written 0.7.
Question 2
A DECLARE Height : INTEGER
B Height ← 1.75
C OUTPUT Height
Line A — Height stores 1.75, which has a fractional part. An INTEGER cannot hold it, so the variable must be declared as REAL.
Question 3
A DECLARE TotalToPay : REAL
B TotalToPay ← 0.0
C TotalToPay ← 9,99
D OUTPUT TotalToPay
Line C — A REAL literal uses a decimal point, not a comma. It should be 9.99.
Question 4
A DECLARE Temp : REAL
B Temp ← 21.5
C Temp ← -4.
D OUTPUT Temp
Line C — A REAL literal needs a digit after the decimal point as well as before it. -4. should be -4.0.
Question 5
A DECLARE Mass : REAL
B DECLARE Count : INTEGER
C Count ← 5.0
D OUTPUT Count
Line C — 5.0 is a REAL value, but Count is an INTEGER. The whole number 5 must be assigned instead.

Student with a class code? Join your class →