← IGCSE Computer Science Paper 2

INTEGER data type

The data type for a whole number with no fractional part, written in denary digits, such as 5 or -3. Used for counts like lives: DECLARE Lives : INTEGER

Understanding INTEGER data type in IGCSE Computer Science Paper 2

What it does: Counter is declared as INTEGER, so it can store whole numbers like 0, 5 or 12 but not a value like 2.5. 5 is a whole number written in denary digits, so it can be assigned to an INTEGER variable. -5 would also be valid. Lives is a count of whole things, so INTEGER is the right data type. STRING is for text. 42.0 is written with a decimal point, so it is a REAL literal. 42 has no fractional part, so it is an INTEGER. A DECLARE statement uses a colon between the identifier and the data type, not an equals sign.

Common mistakes: Lives is an INTEGER, so it can only hold whole numbers. Subtracting 0.5 gives a value with a fractional part. It should subtract a whole number such as 1. An INTEGER variable cannot store a number with a fractional part. 2.5 is a REAL value. It should add a whole number such as 5.

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 can be stored in an INTEGER variable?
3.5-3
Matches
DECLARE Lives : INTEGER Lives ← 2.5
↓
2.5 has a fractional part, so it cannot be stored in an INTEGER variable. Use a whole number such as 2, or declare Lives as REAL.
Applying
Meanings
Term
INTEGER
Meaning
The data type for a whole number with no fractional part, written in denary digits, such as 5 or -3. Used for counts like lives: DECLARE Lives : INTEGER
Practice
DECLARE Lives : INTEGER
Testing
Gaps
DECLARE Lives :
Check Answer
Spots
2Lives ← 3
3Lives ← Lives - 0.5

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

The 'Dolphin' badge — Reef Streak, 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 can be stored in an INTEGER variable?
A. -3 ✓
B. 3.5
INTEGER holds whole numbers only. Negative whole numbers like -3 are allowed, but 3.5 has a fractional part so it needs REAL.
2. Which declaration creates a variable to store the number of lives a player has?
A. DECLARE Lives : INTEGER ✓
B. DECLARE Lives : STRING
Lives is a count of whole things, so INTEGER is the right data type. STRING is for text.
3. True or false: an INTEGER can be negative.
A. False, it must be 0 or more
B. True, for example -3 ✓
INTEGER covers all whole numbers, including negative ones and zero.
4. Which is a valid INTEGER literal?
A. 42.0
B. 42 ✓
42.0 is written with a decimal point, so it is a REAL literal. 42 has no fractional part, so it is an INTEGER.
5. Which value is best stored as an INTEGER?
A. The number of students in a class ✓
B. The average height of the students in metres
A count of students is always a whole number. An average height usually has a fractional part and needs REAL.

Match the Pairs

DECLARE Lives : INTEGER → Creates a variable called Lives that can store a whole number, such as the number of lives left in a game
Score ← -3 → Stores a negative whole number in the variable Score, which is a valid INTEGER value
An INTEGER variable holds a whole number with no fractional part, such as a count of items → DECLARE Counter : INTEGER
A valid INTEGER value is written in normal denary digits and can be positive or negative → Counter ← 5
DECLARE Lives : INTEGER Lives ← 2.5 → 2.5 has a fractional part, so it cannot be stored in an INTEGER variable. Use a whole number such as 2, or declare Lives as REAL.
DECLARE Counter : INTEGER Counter ← "5" → "5" is a STRING because it is in quotes, so it does not match INTEGER. Write the whole number 5 without quotes.

Key Term

INTEGER
The data type for a whole number with no fractional part, written in denary digits, such as 5 or -3. Used for counts like lives: DECLARE Lives : INTEGER

Fill in the Blanks

1. DECLARE Lives : INTEGER
Hint: Type the data type used for whole numbers with no fractional part.
2. DECLARE Change : INTEGER Change ← -3
Hint: Type the data type that can store a negative whole number like the one assigned.
3. DECLARE Counter : INTEGER Counter ← 0
Hint: Type the keyword that creates a variable and gives it a data type.
4. DECLARE Lives : INTEGER Lives ← 3
Hint: Type the name of the variable that was declared on the line above.
5. DECLARE Counter : INTEGER Counter ← 0 Counter ← Counter + 1
Hint: Type the arithmetic operator that increases the count by one.

Spot the Error

Question 1
A DECLARE Lives : INTEGER
B Lives ← 3
C Lives ← Lives - 0.5
D OUTPUT Lives
Line C — Lives is an INTEGER, so it can only hold whole numbers. Subtracting 0.5 gives a value with a fractional part. It should subtract a whole number such as 1.
Question 2
A DECLARE Score : INTEGER
B Score ← 0
C Score ← Score + 10
D Score ← Score + 2.5
E OUTPUT Score
Line D — An INTEGER variable cannot store a number with a fractional part. 2.5 is a REAL value. It should add a whole number such as 5.
Question 3
A DECLARE Temp : INTEGER
B Temp ← "-3"
C OUTPUT Temp
Line B — The quote marks make "-3" a STRING, not an INTEGER. A negative integer is written with a minus sign and digits only, with no quotes: Temp ← -3.
Question 4
A DECLARE Count : INT
B Count ← 7
C OUTPUT Count
Line A — The Cambridge pseudocode data type for whole numbers is spelled INTEGER, not INT. It should be DECLARE Count : INTEGER.
Question 5
A DECLARE Players : INTEGER
B Players ← 4.0
C OUTPUT Players
Line B — 4.0 is written with a decimal point, so it is a REAL literal, not an INTEGER literal. A whole number is written with digits only: Players ← 4.

Student with a class code? Join your class →