← IGCSE Computer Science Paper 2

STRING data type

The data type for text: zero or more characters written between double quotes, such as "This is a string". "" is the empty string and "123" is text, not a number.

Understanding STRING data type in IGCSE Computer Science Paper 2

What it does: The double quotes mark the start and end of the STRING value being assigned. The Cambridge data type for text is STRING. TEXT is not a Cambridge pseudocode data type. A STRING can hold zero or more characters, so "" is a valid STRING called the empty string. 4096 without quotes is an INTEGER, which doesn't match a STRING variable. "4096" is a STRING.

Common mistakes: A STRING literal must start and end with double quotes. The closing quote is missing after Hi. It should be OUTPUT "Hi ", Name. TEXT is not a Cambridge pseudocode data type. The data type for text is STRING, so the line should be DECLARE Pet : STRING.

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 is a valid STRING literal in Cambridge pseudocode?
'Hello World'"Hello World"
Matches
Name ← Sam
↓
The text has no double quotes, so it is not a STRING literal. It should be Name ← "Sam".
Applying
Meanings
Term
STRING
Meaning
The data type for text: zero or more characters written between double quotes, such as "This is a string". "" is the empty string and "123" is text, not a number.
Practice
DECLARE Greeting : STRING
Testing
Gaps
DECLARE UserName :
Check Answer
Spots
2Name ← "Ava"
3OUTPUT "Hi , Name

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

The 'Starfish' badge — Five-Point Star, 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 is a valid STRING literal in Cambridge pseudocode?
A. 'Hello World'
B. "Hello World" ✓
STRING values are written between double quotes. Single quotes are used for CHAR values, and only for one character.
2. Which line correctly declares a variable to store a person's name?
A. DECLARE Name : STRING ✓
B. DECLARE Name : TEXT
The Cambridge data type for text is STRING. TEXT is not a Cambridge pseudocode data type.
3. What is "" in pseudocode?
A. The empty string, a STRING with zero characters ✓
B. An error, because a STRING must have at least one character
A STRING can hold zero or more characters, so "" is a valid STRING called the empty string.
4. What is the data type of "123"?
A. STRING, because it is in double quotes ✓
B. INTEGER, because it only contains digits
Anything inside double quotes is a STRING, so "123" is text. You cannot use it in calculations as a number.
5. What is the data type of "A"?
A. CHAR, because it is one character long
B. STRING, because it uses double quotes ✓
A CHAR literal is written in single quotes, like 'A'. A one-character value in double quotes is still a STRING.

Match the Pairs

DECLARE Name : STRING → Creates a variable that can store text made of zero or more characters
Text ← "" → Stores the empty string, which has zero characters, in Text
A STRING literal is written between double quotes → Greeting ← "Hello, Sam"
Digits inside double quotes are text, not a number, so they are a STRING → Code ← "123"
Name ← Sam → The text has no double quotes, so it is not a STRING literal. It should be Name ← "Sam".
DECLARE Pin : INTEGER Pin ← "1234" → "1234" is a STRING because of the double quotes, so it cannot be assigned to an INTEGER variable. Declare Pin as STRING or assign 1234.

Key Term

STRING
The data type for text: zero or more characters written between double quotes, such as "This is a string". "" is the empty string and "123" is text, not a number.

Fill in the Blanks

1. DECLARE UserName : STRING
Hint: Type the data type used for a sequence of characters such as a name.
2. DECLARE Message : STRING Message ← ""
Hint: Type the name of the variable declared on the line above, which is being set to a string with zero characters.
3. DECLARE PhoneNumber : STRING PhoneNumber ← "0123456789"
Hint: Phone numbers are text, not numbers to calculate with. Type the data type that suits them.
4. DECLARE Word : STRING Word ← "A"
Hint: Type the keyword that creates a variable before its name and data type.
5. DECLARE Reply : STRING Reply ← "123"
Hint: Type the assignment operator that stores the text value in the variable.

Spot the Error

Question 1
A DECLARE Name : STRING
B Name ← "Ava"
C OUTPUT "Hi , Name
Line C — A STRING literal must start and end with double quotes. The closing quote is missing after Hi. It should be OUTPUT "Hi ", Name.
Question 2
A DECLARE Pet : TEXT
B Pet ← "Cat"
C OUTPUT Pet
Line A — TEXT is not a Cambridge pseudocode data type. The data type for text is STRING, so the line should be DECLARE Pet : STRING.
Question 3
A DECLARE Pin : STRING
B Pin ← "1234"
C DECLARE Next : STRING
D Next ← 5678
Line D — Next is a STRING variable, so it must be given text in double quotes. 5678 without quotes is an INTEGER. It should be Next ← "5678".
Question 4
A DECLARE Name : STRING
B INPUT Name
C IF Name = "" THEN
D Name ← Guest
E ENDIF
Line D — Text must be written in double quotes. Without them, Guest looks like an identifier, not a STRING value. It should be Name ← "Guest".
Question 5
A DECLARE Age : INTEGER
B Age ← "15"
C OUTPUT Age + 1
Line B — "15" in double quotes is a STRING, which is text and not a number. Age is an INTEGER, so it needs the number 15 with no quotes: Age ← 15.

Student with a class code? Join your class →