← IGCSE Computer Science Paper 2

INPUT and OUTPUT

INPUT stores a value from the user in a variable, e.g. INPUT Number. OUTPUT shows a message or value on screen, e.g. OUTPUT "Total is ", Total. Prompt first so users know what to enter.

Understanding INPUT and OUTPUT in IGCSE Computer Science Paper 2

What it does: An OUTPUT message before INPUT tells the user what is needed, then INPUT stores the answer in Number. The text in quotes is the label and the variable name after the comma gives the value to display. Prompt first so the user knows what to enter. Otherwise the program waits for a value with no explanation.

Common mistakes: Cambridge pseudocode uses the keyword INPUT to read a value into a variable. Line 2 should be INPUT Number. INPUT is a keyword that comes first, followed by the variable name. It is not used on the right of an assignment. It should be INPUT Number.

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 254–264) and word search (Modules 254–274).

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 from the user into the variable Number?
INPUT = NumberINPUT Number
Matches
INPUT "Enter a number"
↓
INPUT must be followed by a variable name to store the value in, not a message. Use OUTPUT for the message, then INPUT Number.
Applying
Meanings
Term
INPUT and OUTPUT
Meaning
INPUT stores a value from the user in a variable, e.g. INPUT Number. OUTPUT shows a message or value on screen, e.g. OUTPUT "Total is ", Total. Prompt first so users know what to enter.
Practice
DECLARE Number : INTEGER
Testing
Gaps
Number
Check Answer
Spots
1DECLARE Number : INTEGER
2READ Number

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

The 'Badger' badge — Determined Digger, 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 from the user into the variable Number?
A. INPUT Number ✓
B. INPUT = Number
In Cambridge pseudocode, INPUT is followed by the variable name that will store the value. No = sign is used.
2. Which line correctly displays the message Total is followed by the value in Total?
A. OUTPUT "Total is ", Total ✓
B. OUTPUT "Total is ", "Total"
Total without quotes is the variable, so its value is shown. "Total" in quotes would just display the word Total.
3. What is the best order for a program that asks a user for a mark?
A. INPUT Mark then OUTPUT "Enter a mark"
B. OUTPUT "Enter a mark" then INPUT Mark ✓
Prompt first so the user knows what to enter. Otherwise the program waits for a value with no explanation.
4. True or false: INPUT Score stores the value the user types in the variable Score.
A. True ✓
B. False
INPUT reads a value from the user and stores it in the named variable.
5. Which keyword shows a message or value on the screen?
A. INPUT
B. OUTPUT ✓
OUTPUT displays information to the user. INPUT does the opposite and takes information in.

Match the Pairs

INPUT Number → Reads a value typed by the user and stores it in the variable Number
OUTPUT "Total is ", Total → Displays the message Total is followed by the value stored in Total
Prompt the user first so they know what to enter, then read their value → OUTPUT "Enter a number" INPUT Number
Show a variable's value on screen after a text label → OUTPUT "Total is ", Total
INPUT "Enter a number" → INPUT must be followed by a variable name to store the value in, not a message. Use OUTPUT for the message, then INPUT Number.
OUTPUT "Total is ", "Total" → Total is in quotes so the word Total is displayed instead of the variable's value. Remove the quotes around Total.

Key Term

INPUT and OUTPUT
INPUT stores a value from the user in a variable, e.g. INPUT Number. OUTPUT shows a message or value on screen, e.g. OUTPUT "Total is ", Total. Prompt first so users know what to enter.

Fill in the Blanks

1. INPUT Number
Hint: Type the keyword that reads a value from the user and stores it in a variable.
2. OUTPUT "Total is ", Total
Hint: Type the keyword that displays a message and a value on the screen.
3. OUTPUT "Enter a number" INPUT Number Total ← Total + Number
Hint: Type the variable name that will store the value the user enters.
4. Total ← Total + Number OUTPUT "Total is ", Total
Hint: Type the name of the variable whose value is shown after the message.
5. OUTPUT "Enter a mark" INPUT Mark Total ← Total + Mark
Hint: Type the keyword that shows a prompt to the user before they enter a value.

Spot the Error

Question 1
A DECLARE Number : INTEGER
B READ Number
C OUTPUT "You entered ", Number
Line B — Cambridge pseudocode uses the keyword INPUT to read a value into a variable. Line 2 should be INPUT Number.
Question 2
A OUTPUT "Enter a number"
B Number ← INPUT
C OUTPUT "Number is ", Number
Line B — INPUT is a keyword that comes first, followed by the variable name. It is not used on the right of an assignment. It should be INPUT Number.
Question 3
A OUTPUT Enter your age
B INPUT Age
C OUTPUT "Age is ", Age
Line A — A message to display must be inside double quotes. Without them the computer reads the words as variable names. It should be OUTPUT "Enter your age".
Question 4
A OUTPUT "Enter first number"
B INPUT Num1
C OUTPUT "You typed " Num1
Line C — Items in an OUTPUT statement must be separated by commas. The comma is missing after the message. It should be OUTPUT "You typed ", Num1.
Question 5
A DECLARE Total : INTEGER
B Total ← 15
C OUTPUT "Total is ", "Total"
Line C — Putting Total in quotes outputs the word Total instead of the value stored in the variable. It should be OUTPUT "Total is ", Total.

Student with a class code? Join your class →