← IGCSE Computer Science Paper 2

Choosing between CHAR and STRING

Use CHAR for a value that is always exactly one character, like a grade letter or Y/N. Use STRING for text of any length, including none, like a name or phone number.

Understanding Choosing between CHAR and STRING in IGCSE Computer Science Paper 2

What it does: Names vary in length (Al, Alexandra), so STRING is needed rather than CHAR. An answer of 'Y' or 'N' is exactly one character, so CHAR is the best choice. A phone number is not used in calculations, and an INTEGER would lose the leading zero. Store it as STRING. A city name such as "Paris" has many characters, so it needs STRING. A grade letter is always a single character, so CHAR is the right data type.

Common mistakes: A phone number is not used in calculations and can start with 0, so it must be STRING. INTEGER would drop the leading zero. It should be DECLARE Phone : STRING. Single quotes make a CHAR literal, which holds exactly one character. A name is a STRING and needs double quotes: Name ← "Sam".

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
Which data type suits a grade letter such as 'B'?
STRINGCHAR
Matches
DECLARE Surname : CHAR
↓
A surname can be many characters long, so it needs STRING, not CHAR. CHAR holds only one character.
Applying
Meanings
Term
CHAR or STRING
Meaning
Use CHAR for a value that is always exactly one character, like a grade letter or Y/N. Use STRING for text of any length, including none, like a name or phone number.
Practice
DECLARE Grade : CHAR
Testing
Gaps
DECLARE Grade :
Check Answer
Spots
1DECLARE Phone : INTEGER
2INPUT Phone

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

The 'Butterfly' badge — Branch Hopper, 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 suits a grade letter such as 'B'?
A. CHAR ✓
B. STRING
A grade letter is always exactly one character, so CHAR is the best choice.
2. Which data type suits a student's name?
A. STRING ✓
B. CHAR
Names have different lengths, so they need STRING. CHAR holds only one character.
3. Which data type suits a phone number such as "07700900123"?
A. STRING ✓
B. INTEGER
A phone number is not used in calculations, and an INTEGER would lose the leading zero. Store it as STRING.
4. A program asks 'Do you want to continue? (Y/N)'. Which type stores the answer?
A. STRING
B. CHAR ✓
The answer is always one character, 'Y' or 'N', so CHAR fits.
5. Which statement is true?
A. A CHAR can hold any length of text, including none
B. A STRING can hold any length of text, including none ✓
Only STRING can be any length, even empty (""). CHAR is always exactly one character.

Match the Pairs

DECLARE Grade : CHAR → Grade holds exactly one character, such as a grade letter like A, B or C
DECLARE PhoneNumber : STRING → PhoneNumber holds text of any length; digits are stored as text because they are not used in calculations
A name can be any length, so it should be stored as a STRING → DECLARE FirstName : STRING
A yes or no answer of 'Y' or 'N' is always one character, so it is a CHAR → DECLARE Answer : CHAR
DECLARE Surname : CHAR → A surname can be many characters long, so it needs STRING, not CHAR. CHAR holds only one character.
DECLARE Grade : STRING Grade ← "A" → A grade letter is always exactly one character, so CHAR is the better choice. The CHAR literal would also use single quotes: 'A'.

Key Term

CHAR or STRING
Use CHAR for a value that is always exactly one character, like a grade letter or Y/N. Use STRING for text of any length, including none, like a name or phone number.

Fill in the Blanks

1. DECLARE Grade : CHAR Grade ← 'B'
Hint: Type the data type for a value that is always exactly one character, like a grade letter.
2. DECLARE FirstName : STRING FirstName ← "Priya"
Hint: Type the data type for a name, which can be any number of characters.
3. DECLARE PhoneNumber : STRING PhoneNumber ← "07700900123"
Hint: Type the data type for a phone number. It is never used in calculations and has many digits.
4. DECLARE Answer : CHAR OUTPUT "Continue? (Y/N)" INPUT Answer
Hint: Type the data type for a reply that is always a single letter, either Y or N.
5. DECLARE Comment : STRING Comment ← ""
Hint: Type the data type that can hold text of any length, including no characters at all.

Spot the Error

Question 1
A DECLARE Phone : INTEGER
B INPUT Phone
C OUTPUT Phone
Line A — A phone number is not used in calculations and can start with 0, so it must be STRING. INTEGER would drop the leading zero. It should be DECLARE Phone : STRING.
Question 2
A DECLARE Grade : CHAR
B Grade ← 'B'
C DECLARE Name : STRING
D Name ← 'Sam'
Line D — Single quotes make a CHAR literal, which holds exactly one character. A name is a STRING and needs double quotes: Name ← "Sam".
Question 3
A DECLARE Answer : CHAR
B Answer ← "Yes"
C OUTPUT Answer
Line B — A CHAR holds exactly one character, and "Yes" is a three-character STRING. For a Y/N answer use the single character 'Y'.
Question 4
A DECLARE Surname : STRING
B Surname ← ""
C Initial ← ''
Line C — A CHAR must be exactly one character, so it cannot be empty. Only a STRING can be empty. It should be Initial ← 'K' with one character between the quotes.
Question 5
A DECLARE FirstName : CHAR
B INPUT FirstName
C OUTPUT FirstName
Line A — A name can be any length, so it needs STRING. A CHAR can only hold one character. It should be DECLARE FirstName : STRING.

Student with a class code? Join your class →