← IGCSE Computer Science Paper 2

INPUT

INPUT followed by a variable name reads a value typed by the user and stores it in that variable. Use one variable per INPUT, and OUTPUT a prompt first.

Understanding INPUT in IGCSE Computer Science Paper 2

What it does: OUTPUT displays the prompt so the user knows what to type, then INPUT reads the reply into Age. INPUT is followed by the identifier (variable name) with no quotes. The value the user types is stored in that variable. Use one variable per INPUT. To read two values, write two INPUT statements, for example INPUT Width then INPUT Height. To store a value in one array element, give the index in square brackets. INPUT Marks on its own does not say which element to fill. The fix is OUTPUT "Enter a number" followed by INPUT Number.

Common mistakes: Pseudocode uses the keyword INPUT to read a value typed by the user. READ is not a pseudocode keyword. It should be INPUT Name. INPUT must name the variable that was declared. Aged is a different, undeclared variable, so the value would not be stored in Age. It 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 156–165) and word search (Modules 146–165).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which line correctly reads a value typed by the user into a variable called Answer?
INPUT AnswerINPUT "Answer"
Matches
INPUT Length, Width
↓
Two variables are listed in one INPUT. Each INPUT must read into only one variable.
Applying
Meanings
Term
INPUT Answer
Meaning
INPUT followed by a variable name reads a value typed by the user and stores it in that variable. Use one variable per INPUT, and OUTPUT a prompt first.
Practice
DECLARE Answer : STRING
Testing
Gaps
Answer
Check Answer
Spots
1OUTPUT "Enter your name"
2READ Name

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

The 'Nautilus' badge — Default Expert, 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 correctly reads a value typed by the user into a variable called Answer?
A. INPUT Answer ✓
B. INPUT "Answer"
INPUT is followed by the identifier (variable name) with no quotes. The value the user types is stored in that variable.
2. Which line reads a value into a variable called Age?
A. INPUT Age ✓
B. Age INPUT
The keyword INPUT comes first, then the variable name. Writing the variable first is not valid Cambridge pseudocode.
3. Which is the correct way to ask for a name, then read it?
A. OUTPUT "Enter your name" INPUT Name ✓
B. INPUT Name OUTPUT "Enter your name"
OUTPUT the prompt first so the user knows what to type. If INPUT comes first, the program waits with no message shown.
4. Which statement is true about INPUT?
A. One INPUT can read several variables at once
B. Each INPUT reads one value into one variable ✓
Use one variable per INPUT. To read two values, write two INPUT statements, for example INPUT Width then INPUT Height.
5. Which correctly reads two values, Width and Height?
A. INPUT Width, Height
B. INPUT Width INPUT Height ✓
Each INPUT statement has only one variable. Use a separate INPUT line for each value.

Match the Pairs

INPUT Answer → Reads a value typed by the user and stores it in the variable Answer
INPUT Scores[3] → Reads a value typed by the user and stores it in element 3 of the array Scores
Show a prompt with OUTPUT first, then read the user's reply into a variable → OUTPUT "Enter your age" INPUT Age
Use one variable per INPUT, so two values need two INPUT statements → INPUT Length INPUT Width
INPUT Length, Width → Two variables are listed in one INPUT. Each INPUT must read into only one variable.
INPUT "Enter a number" → A prompt in quotes is placed after INPUT instead of a variable name. INPUT needs a variable, and the prompt belongs in an OUTPUT statement.

Key Term

INPUT Answer
INPUT followed by a variable name reads a value typed by the user and stores it in that variable. Use one variable per INPUT, and OUTPUT a prompt first.

Fill in the Blanks

1. INPUT Answer
Hint: Type the keyword that reads a value typed by the user into a variable.
2. DECLARE Age : INTEGER OUTPUT "Enter your age: " INPUT Age
Hint: Type the variable name that will store the value the user types.
3. INPUT Width INPUT Height
Hint: Each variable needs its own statement. Type the keyword that reads the second value.
4. FOR Index ← 1 TO 5 INPUT Scores[Index] NEXT Index
Hint: Type the loop variable that selects which array element receives the input.
5. OUTPUT "Enter your name: " INPUT Name
Hint: Type the keyword that displays a prompt to the user before the INPUT statement.

Spot the Error

Question 1
A OUTPUT "Enter your name"
B READ Name
C OUTPUT "Hello ", Name
Line B — Pseudocode uses the keyword INPUT to read a value typed by the user. READ is not a pseudocode keyword. It should be INPUT Name.
Question 2
A DECLARE Age : INTEGER
B OUTPUT "Enter your age"
C INPUT Aged
D OUTPUT Age
Line C — INPUT must name the variable that was declared. Aged is a different, undeclared variable, so the value would not be stored in Age. It should be INPUT Age.
Question 3
A OUTPUT Enter your score
B INPUT Score
C OUTPUT Score
Line A — The prompt is a string, so it must be written inside quotation marks. It should be OUTPUT "Enter your score".
Question 4
A DECLARE A, B : INTEGER
B OUTPUT "Enter two numbers"
C INPUT A, B
D INPUT B
E OUTPUT A + B
Line C — Each INPUT reads into one variable only. Using INPUT A, B breaks the one-variable-per-INPUT rule. It should be INPUT A, with a separate INPUT B on the next line.
Question 5
A DECLARE Number : INTEGER
B OUTPUT "Enter a number"
C OUTPUT "Between 1 and 10"
D INPUT Number + 1
E OUTPUT Number * 2
Line D — INPUT can only be followed by a variable name, not an expression. The calculation must be done after the value has been read. It should be INPUT Number.

Student with a class code? Join your class →