← IGCSE Computer Science Paper 2

Data type keywords: INTEGER, REAL, CHAR, STRING, BOOLEAN

The five data types, in order: whole number, number with a fractional part, one character, zero or more characters, TRUE or FALSE. A phone number is a STRING.

Understanding Data type keywords: INTEGER, REAL, CHAR, STRING, BOOLEAN in IGCSE Computer Science Paper 2

What it does: Phone numbers and postcodes are identifiers, not quantities, so they are STRING values. An INTEGER would drop a leading 0. REAL holds numbers with a fractional part. INTEGER can only hold whole numbers, so it cannot store 3.75. CHAR holds a single character. A STRING holds zero or more characters, so it is used for longer text. BOOLEAN holds only TRUE or FALSE. It is the right type for yes/no values. A type check confirms the input is the expected data type. A whole number age is an INTEGER, so a value like 14.5 would fail.

Common mistakes: Age is an INTEGER, so it can only hold a whole number. 15.5 has a fractional part. It should be a whole number such as 15, or Age should be declared as REAL. The Cambridge keyword for a single character is CHAR, not CHARACTER. It should be DECLARE Initial : CHAR.

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 17–26) and word search (Modules 1–26).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which data type should a variable holding a student's age in whole years use?
STRINGINTEGER
Matches
DECLARE Postcode : INTEGER
↓
A postcode can start with 0 or contain letters, and you never do sums with it. It should be a STRING, not an INTEGER.
Applying
Meanings
Term
INTEGER, REAL, CHAR, STRING, BOOLEAN
Meaning
The five data types, in order: whole number, number with a fractional part, one character, zero or more characters, TRUE or FALSE. A phone number is a STRING.
Practice
DECLARE Age : INTEGER
Testing
Gaps
DECLARE Age :
Check Answer
Spots
3Price ← 2.50
4Age ← 15.5

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

The 'Parrotfish' badge — Function Builder, 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 data type should a variable holding a student's age in whole years use?
A. STRING
B. INTEGER ✓
A whole number with no fractional part is an INTEGER. You can do arithmetic with it, such as working out next year's age.
2. Which data type suits a price such as 4.75?
A. REAL ✓
B. INTEGER
REAL holds numbers with a fractional part. An INTEGER cannot store the .75.
3. Which data type is best for a phone number such as 07911123456?
A. INTEGER
B. STRING ✓
A phone number is a STRING. You never do arithmetic on it, and an INTEGER would drop the leading 0.
4. Which data type holds exactly one letter, such as a grade 'B'?
A. CHAR ✓
B. STRING
CHAR holds a single character. A STRING holds zero or more characters, so it is used for longer text.
5. Which data type suits a postcode such as SW1A 2AA?
A. STRING ✓
B. CHAR
A postcode has several characters, including letters, digits and a space, so it is a STRING. A CHAR holds only one character.

Match the Pairs

DECLARE Age : INTEGER → Age can hold only whole numbers, such as 15 or 42, with no fractional part.
DECLARE Grade : CHAR → Grade holds exactly one character, such as 'A'.
A phone number or postcode must be stored as a STRING, because it can start with 0 and is never used in sums. → DECLARE PhoneNumber : STRING
A price such as 3.75 has a fractional part, so it needs the REAL data type, not INTEGER. → DECLARE Price : REAL
DECLARE Postcode : INTEGER → A postcode can start with 0 or contain letters, and you never do sums with it. It should be a STRING, not an INTEGER.
DECLARE IsLoggedIn : STRING → A value that is only TRUE or FALSE should use the BOOLEAN data type, not STRING.

Key Term

INTEGER, REAL, CHAR, STRING, BOOLEAN
The five data types, in order: whole number, number with a fractional part, one character, zero or more characters, TRUE or FALSE. A phone number is a STRING.

Fill in the Blanks

1. DECLARE Age : INTEGER
Hint: Type the data type used for a whole number such as an age.
2. DECLARE Price : REAL
Hint: Type the data type for a number that can have a fractional part, like a price.
3. DECLARE Grade : CHAR
Hint: Type the data type that holds exactly one character, like a letter grade.
4. DECLARE PhoneNumber : STRING
Hint: Type the data type for text, which also suits phone numbers because they can start with a zero.
5. DECLARE IsValid : BOOLEAN
Hint: Type the data type for a value that can only be TRUE or FALSE.

Spot the Error

Question 1
A DECLARE Age : INTEGER
B DECLARE Price : REAL
C Price ← 2.50
D Age ← 15.5
Line D — Age is an INTEGER, so it can only hold a whole number. 15.5 has a fractional part. It should be a whole number such as 15, or Age should be declared as REAL.
Question 2
A DECLARE Initial : CHARACTER
B Initial ← 'K'
C OUTPUT Initial
Line A — The Cambridge keyword for a single character is CHAR, not CHARACTER. It should be DECLARE Initial : CHAR.
Question 3
A // Store a phone number
B DECLARE Name : STRING
C INPUT Name
D DECLARE Phone : INTEGER
E INPUT Phone
Line D — A phone number is not used for calculations and often starts with 0, which an INTEGER would drop. It must be a STRING, so: DECLARE Phone : STRING.
Question 4
A DECLARE Passed : BOOLEAN
B Passed ← "TRUE"
C IF Passed = TRUE THEN
D OUTPUT "Well done"
E ENDIF
Line B — A BOOLEAN holds the value TRUE or FALSE, written without quotes. "TRUE" in quotes is a STRING. It should be Passed ← TRUE.
Question 5
A DECLARE Count : INTEGER
B DECLARE Height REAL
C Height ← 1.75
Line B — A declaration needs a colon between the identifier and the data type. It should be DECLARE Height : REAL.

Student with a class code? Join your class →