← IGCSE Computer Science Paper 2

Input with INPUT

Reads a value typed by the user and stores it in the variable named after INPUT (here Answer). Declare the variable first; its data type decides what can be entered.

Understanding Input with INPUT in IGCSE Computer Science Paper 2

What it does: DECLARE sets up the variable and its data type first, so INPUT has somewhere to store the value. The OUTPUT line is the prompt and the INPUT line stores the reply in Number. INPUT reads a value from the user. Displaying a message is the job of OUTPUT. A name is text, so the variable should be a STRING. A BOOLEAN can only hold TRUE or FALSE.

Common mistakes: Cambridge pseudocode uses the keyword INPUT to read a value from the user, not READ. The line should be INPUT Name. INPUT is a statement, not a value to assign. The variable name goes after INPUT, so the line should be INPUT Age.

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 line reads a value from the user into a variable called Age?
INPUT 25INPUT Age
Matches
INPUT "Age"
↓
INPUT needs a variable name (identifier), not a string in quotes. It should be INPUT Age.
Applying
Meanings
Term
INPUT Answer
Meaning
Reads a value typed by the user and stores it in the variable named after INPUT (here Answer). Declare the variable first; its data type decides what can be entered.
Practice
DECLARE Age : INTEGER
Testing
Gaps
Age
Check Answer
Spots
2OUTPUT "Enter your name"
3READ Name

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

The 'Owl' badge — Wise 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 reads a value from the user into a variable called Age?
A. INPUT Age ✓
B. INPUT 25
INPUT is followed by the name of a variable. The typed value is stored in that variable, so a literal like 25 cannot follow INPUT.
2. Which pair of lines is in the correct order?
A. DECLARE Age : INTEGER INPUT Age ✓
B. INPUT Age DECLARE Age : INTEGER
The variable must be declared before it is used. Declare first, then INPUT into it.
3. Where does the value the user types go after INPUT Answer runs?
A. Onto the screen as output
B. Into the variable Answer ✓
INPUT stores the typed value in the named variable. It does not display anything; OUTPUT does that.
4. A variable is declared as DECLARE Score : INTEGER. Which entry can INPUT Score accept?
A. 42 ✓
B. forty-two
The data type decides what can be entered. An INTEGER variable needs a whole number, not words.
5. Which is the better way to ask the user for their name?
A. INPUT Name OUTPUT "Enter your name"
B. OUTPUT "Enter your name" INPUT Name ✓
Use OUTPUT first to show a prompt, so the user knows what to type. Then use INPUT to read the answer.

Match the Pairs

INPUT Age → Waits for the user to type a value and stores it in the variable Age
OUTPUT "Enter your name: " → Shows a prompt so the user knows what to type before the INPUT statement
The variable must be declared before it is used to store the input → DECLARE Score : INTEGER INPUT Score
Ask the user with OUTPUT first, then read their answer with INPUT → OUTPUT "Enter a number: " INPUT Number
INPUT "Age" → INPUT needs a variable name (identifier), not a string in quotes. It should be INPUT Age.
DECLARE Age : INTEGER INPUT Age // user types: hello → Age is an INTEGER, so the user cannot enter text like hello. The type decides what can be entered.

Key Term

INPUT Answer
Reads a value typed by the user and stores it in the variable named after INPUT (here Answer). Declare the variable first; its data type decides what can be entered.

Fill in the Blanks

1. DECLARE Age : INTEGER OUTPUT "Enter your age: " INPUT Age
Hint: Type the keyword that reads a value typed by the user.
2. DECLARE Name : STRING OUTPUT "Enter your name: " INPUT Name
Hint: Type the name of the variable that will store what the user types.
3. DECLARE Score : INTEGER OUTPUT "Enter your score: " INPUT Score
Hint: Type the data type that lets the user enter a whole number.
4. DECLARE Price : REAL OUTPUT "Enter the price: " INPUT Price
Hint: Type the keyword that shows a prompt to the user before the input.
5. DECLARE Colour : STRING OUTPUT "Favourite colour? " INPUT Colour
Hint: Type the keyword that must create the variable before INPUT can store a value in it.

Spot the Error

Question 1
A DECLARE Name : STRING
B OUTPUT "Enter your name"
C READ Name
Line C — Cambridge pseudocode uses the keyword INPUT to read a value from the user, not READ. The line should be INPUT Name.
Question 2
A DECLARE Age : INTEGER
B OUTPUT "Enter your age"
C Age ← INPUT
Line C — INPUT is a statement, not a value to assign. The variable name goes after INPUT, so the line should be INPUT Age.
Question 3
A DECLARE Score : INTEGER
B INPUT Mark
C OUTPUT "You scored ", Score
Line B — Mark was never declared. INPUT must name a declared variable, so the line should be INPUT Score.
Question 4
A DECLARE Price : REAL
B INPUT "Price"
C OUTPUT "Price is ", Price
Line B — INPUT needs a variable identifier, not a string in quotes. There should be no quotes: INPUT Price.
Question 5
A DECLARE Count : INTEGER
B OUTPUT "How many?"
C INPUT Count
D OUTPUT "You chose " Count
Line D — Several values in one OUTPUT must be separated by commas. The comma is missing after the text: OUTPUT "You chose ", Count.

Student with a class code? Join your class →