← IGCSE Computer Science Paper 2

Choosing a suitable data type for a value

Pick INTEGER, REAL, CHAR, STRING or BOOLEAN by what the value is and what you do with it, then justify with 'because'. Eg price is REAL because it has pence.

Understanding Choosing a suitable data type for a value in IGCSE Computer Science Paper 2

What it does: A whole number used in calculations is stored as INTEGER, and the 'because' reason justifies the choice. One character only means CHAR is the suitable type for an initial. Prices usually include pence, so they need REAL. INTEGER would lose the decimal part. CHAR holds exactly one character. An address is many characters of text (and includes numbers and spaces), so it is a STRING. A fact with only two possible values points to BOOLEAN. It is simpler and safer than storing text. A mark needs a reason linked to the value. Say why the type fits, for example that the price can have pence, rather than just repeating the data name.

Common mistakes: Whether someone is a member has only two possible values (yes or no), so it should be BOOLEAN, not STRING. Correct line: DECLARE IsMember : BOOLEAN. A price has pence, so it needs decimal places. It must be REAL because INTEGER only stores whole numbers. Correct line: DECLARE Price : 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 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.

Learning
Duo
A program stores a student's age in whole years. Which data type and reason is best?
INTEGER because age in whole years is a whole numberREAL because age is a number
Matches
DECLARE Address : INTEGER
↓
An address is text made of letters, numbers and spaces and is never used in calculations, so it should be STRING, not INTEGER
Applying
Meanings
Term
data type
Meaning
Pick INTEGER, REAL, CHAR, STRING or BOOLEAN by what the value is and what you do with it, then justify with 'because'. Eg price is REAL because it has pence.
Practice
DECLARE Age : INTEGER // whole number of years
Testing
Gaps
DECLARE Age :
Check Answer
Spots
3DECLARE Initial : CHAR
4DECLARE IsMember : STRING

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

The 'Owl' badge — Wise Coder, 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. A program stores a student's age in whole years. Which data type and reason is best?
A. INTEGER because age in whole years is a whole number ✓
B. REAL because age is a number
Whole-number values such as an age in years use INTEGER. REAL is only needed when the value can have a decimal part.
2. A program stores the price of a notebook, such as 4.75. Which data type and reason is best?
A. REAL because the price has pence (a decimal part) ✓
B. INTEGER because a price is a number
Prices usually include pence, so they need REAL. INTEGER would lose the decimal part.
3. A program stores a member's initial, for example 'J'. Which data type is best?
A. STRING because it is a name
B. CHAR because it is a single character ✓
One single character is CHAR. STRING is for text of any length, but the initial is only one character.
4. A program stores an address such as "12 High Street". Which data type is best?
A. CHAR because it is one piece of data
B. STRING because it is several characters of text ✓
CHAR holds exactly one character. An address is many characters of text (and includes numbers and spaces), so it is a STRING.
5. A program records whether a customer is a member: either yes or no. Which data type is best?
A. BOOLEAN because it has only two possible values (TRUE or FALSE) ✓
B. STRING because it could be typed as the word yes or no
A fact with only two possible values points to BOOLEAN. It is simpler and safer than storing text.

Match the Pairs

DECLARE Price : REAL → Price holds a money amount with pence, so it needs a number type that can store decimal places
DECLARE IsMember : BOOLEAN → IsMember holds a two-valued fact that is either TRUE or FALSE, so BOOLEAN is chosen
An age is a whole number that is used in calculations, so it is INTEGER because it has no decimal part → DECLARE Age : INTEGER
A single letter such as a first initial is stored as CHAR because it is exactly one character → DECLARE Initial : CHAR
DECLARE Address : INTEGER → An address is text made of letters, numbers and spaces and is never used in calculations, so it should be STRING, not INTEGER
DECLARE Price : INTEGER → A price has pence, so INTEGER would lose the decimal part. It should be REAL because it can hold decimals

Key Term

data type
Pick INTEGER, REAL, CHAR, STRING or BOOLEAN by what the value is and what you do with it, then justify with 'because'. Eg price is REAL because it has pence.

Fill in the Blanks

1. // a person's age in whole years DECLARE Age : INTEGER
Hint: Type the data type for a whole number with no decimal part.
2. // a price such as 2.50 with pence DECLARE Price : REAL
Hint: Type the data type for a number that can have a decimal part.
3. // the first letter of a name DECLARE Initial : CHAR
Hint: Type the data type for exactly one single character.
4. // is the customer a member? TRUE or FALSE DECLARE IsMember : BOOLEAN
Hint: Type the data type for a two-valued fact that is either true or false.
5. // house number, street and town DECLARE Address : STRING
Hint: Type the data type for text made of several characters, including digits and letters.

Spot the Error

Question 1
A DECLARE Age : INTEGER
B DECLARE Price : REAL
C DECLARE Initial : CHAR
D DECLARE IsMember : STRING
Line D — Whether someone is a member has only two possible values (yes or no), so it should be BOOLEAN, not STRING. Correct line: DECLARE IsMember : BOOLEAN.
Question 2
A DECLARE Price : INTEGER
B Price ← 4.75
C OUTPUT Price
Line A — A price has pence, so it needs decimal places. It must be REAL because INTEGER only stores whole numbers. Correct line: DECLARE Price : REAL.
Question 3
A DECLARE Initial : CHAR
B Initial ← 'Kim'
C OUTPUT Initial
Line B — An initial is one character, so a CHAR variable can only hold a single character such as 'K'. 'Kim' is three characters and belongs in a STRING.
Question 4
A DECLARE Age : INTEGER
B Age ← 15
C DECLARE IsMember : BOOLEAN
D IsMember ← "TRUE"
Line D — With quote marks, "TRUE" is a STRING, not a BOOLEAN. A BOOLEAN value is written without quotes. Correct line: IsMember ← TRUE.
Question 5
A DECLARE Price : REAL
B DECLARE Qty : BOOLEAN
C DECLARE Total : REAL
D Total ← Price * Qty
Line B — A quantity is a whole number that is used in a calculation, so it should be INTEGER. BOOLEAN is only for two-valued facts such as TRUE or FALSE. Correct line: DECLARE Qty : INTEGER.

Student with a class code? Join your class →