← IGCSE Computer Science Paper 2

Declaring CHAR and STRING variables

DECLARE creates a variable and sets its type. Here Initial can hold one CHAR (a single character). Use : STRING instead for text, e.g. DECLARE FirstName : STRING.

Understanding Declaring CHAR and STRING variables in IGCSE Computer Science Paper 2

What it does: Two variables means two DECLARE lines, and each line gives its variable exactly one type. A town name is made of many characters, so the variable needs the type STRING, not CHAR. A declaration uses a colon between the name and the type. The = sign is not used in DECLARE. The fix is DECLARE Initial : CHAR on one line and DECLARE Surname : STRING on the next.

Common mistakes: A STRING literal is written in double quotes. Single quotes are for a CHAR. It should be FirstName ← "Ava". Grade is a CHAR, so it can hold only one character. 'BC' has two characters. Use a single character such as 'B', or declare Grade as 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 307–316) and word search (Modules 296–316).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which line declares a variable called Initial that holds a single character?
DECLARE CHAR : InitialDECLARE Initial : CHAR
Matches
DECLARE Initial, Surname : CHAR
↓
Two variables are declared on one line. Each variable needs its own DECLARE line with its own type, and a surname is text, so it should be STRING.
Applying
Meanings
Term
DECLARE Initial : CHAR
Meaning
DECLARE creates a variable and sets its type. Here Initial can hold one CHAR (a single character). Use : STRING instead for text, e.g. DECLARE FirstName : STRING.
Practice
DECLARE Initial : CHAR
Testing
Gaps
Initial : CHAR
Check Answer
Spots
2DECLARE FirstName : STRING
3FirstName ← 'Ava'

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

The 'Manta Ray' badge — Graceful 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. Which line declares a variable called Initial that holds a single character?
A. DECLARE Initial : CHAR ✓
B. DECLARE CHAR : Initial
The pattern is DECLARE, then the variable name, then a colon, then the type. The name comes before the type.
2. Which line declares FirstName so it can hold text such as "Maya"?
A. DECLARE FirstName = STRING
B. DECLARE FirstName : STRING ✓
A declaration uses a colon between the name and the type. The = sign is not used in DECLARE.
3. A variable called Grade will always hold exactly one letter, such as 'B'. Which type fits best?
A. CHAR ✓
B. STRING
CHAR holds a single character. STRING is for text made of any number of characters.
4. A variable called Town will hold names such as "Manchester". Which type should you declare?
A. STRING ✓
B. CHAR
A town name is several characters long, so it needs STRING. CHAR can only hold one character.
5. Which line is a valid declaration?
A. Surname : STRING
B. DECLARE Surname : STRING ✓
The DECLARE keyword must start the line. Without it, the variable is not declared.

Match the Pairs

DECLARE Initial : CHAR → Creates a variable called Initial that can hold a single character, such as 'A'
DECLARE FirstName : STRING → Creates a variable called FirstName that can hold text of any length, such as "Ava"
Each variable needs its own DECLARE line with one type, so declare a CHAR variable and a STRING variable on separate lines → DECLARE Grade : CHAR DECLARE Surname : STRING
Declare a variable to hold a whole word or sentence, such as a town name → DECLARE Town : STRING
DECLARE Initial, Surname : CHAR → Two variables are declared on one line. Each variable needs its own DECLARE line with its own type, and a surname is text, so it should be STRING.
DECLARE FirstName STRING → The colon is missing between the identifier and the data type.

Key Term

DECLARE Initial : CHAR
DECLARE creates a variable and sets its type. Here Initial can hold one CHAR (a single character). Use : STRING instead for text, e.g. DECLARE FirstName : STRING.

Fill in the Blanks

1. DECLARE Initial : CHAR
Hint: Type the keyword that creates a new variable.
2. DECLARE Initial : CHAR
Hint: Type the data type that holds a single character.
3. DECLARE FirstName : STRING
Hint: Type the data type that holds a piece of text.
4. DECLARE Initial : CHAR DECLARE FirstName : STRING
Hint: This second variable holds a whole name. Type its data type.
5. DECLARE Initial : CHAR DECLARE FirstName : STRING
Hint: Type the symbol that separates the variable name from its type.

Spot the Error

Question 1
A DECLARE Initial : CHAR
B DECLARE FirstName : STRING
C FirstName ← 'Ava'
Line C — A STRING literal is written in double quotes. Single quotes are for a CHAR. It should be FirstName ← "Ava".
Question 2
A DECLARE Grade : CHAR
B Grade ← 'BC'
C OUTPUT Grade
Line B — Grade is a CHAR, so it can hold only one character. 'BC' has two characters. Use a single character such as 'B', or declare Grade as STRING.
Question 3
A DECLARE Initial : CHAR
B DECLARE City : STRING
C DECLARE Country STRING
Line C — A DECLARE line needs a colon between the variable name and its type. It should be DECLARE Country : STRING.
Question 4
A DECLARE Letter : CHARACTER
B Letter ← 'Q'
C OUTPUT Letter
Line A — CHARACTER is not a Cambridge data type. The type for a single character is CHAR. It should be DECLARE Letter : CHAR.
Question 5
A DECLARE Initial : CHAR
B DECLARE LastName : STRING
C LastName = "Khan"
Line C — A value is assigned to a variable with the ← operator. The = sign is used for comparison. It should be LastName ← "Khan".

Student with a class code? Join your class →