← IGCSE Computer Science Paper 2

INPUT and OUTPUT statements

INPUT stores a value the user types into a variable. OUTPUT displays a message or value on screen. Show several items by separating them with commas.

Understanding INPUT and OUTPUT statements in IGCSE Computer Science Paper 2

What it does: The OUTPUT line tells the user what to type, then INPUT stores the answer in Number. The comma separates the text from the variable so both appear together in one OUTPUT statement. Items in an OUTPUT statement must be separated by commas. A text message needs a pair of double quotation marks, one at the start and one at the end. Without quotes, OUTPUT displays the value stored in the variable. With quotes, it would show the word Total.

Common mistakes: INPUT must be followed by a variable name that will store the typed value. You cannot input into the value 5. It should be INPUT Number. When OUTPUT shows several items, they must be separated by commas. A comma is missing after the message. It should be OUTPUT "Total is ", Total.

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 358–368) and word search (Modules 358–378).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which line stores a value typed by the user in the variable Number?
OUTPUT NumberINPUT Number
Matches
INPUT "Enter a number"
↓
INPUT must be followed by a variable name, not a message. Use OUTPUT for the message, then INPUT Number to store the value.
Applying
Meanings
Term
INPUT and OUTPUT
Meaning
INPUT stores a value the user types into a variable. OUTPUT displays a message or value on screen. Show several items by separating them with commas.
Practice
DECLARE Number : INTEGER
Testing
Gaps
"Total is ", Total
Check Answer
Spots
1DECLARE Number : INTEGER
2INPUT 5

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

The 'Kangaroo Rat' badge — Speed Typer, 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 stores a value typed by the user in the variable Number?
A. INPUT Number ✓
B. OUTPUT Number
INPUT reads a value from the user into a variable. OUTPUT displays a value instead.
2. Which line displays the message Total is followed by the value of Total?
A. OUTPUT "Total is ", Total ✓
B. INPUT "Total is ", Total
OUTPUT shows items on screen. Separate the message and the variable with a comma.
3. Which is the correct way to show several items in one OUTPUT statement?
A. OUTPUT "Score: " Score " points"
B. OUTPUT "Score: ", Score, " points" ✓
Items in an OUTPUT statement must be separated by commas.
4. A program should ask the user for their age and then store it. Which order is best?
A. OUTPUT "Enter your age" then INPUT Age ✓
B. INPUT Age then OUTPUT "Enter your age"
Prompt with OUTPUT first so the user knows what to type, then use INPUT to store the answer.
5. What does the statement INPUT Number do when the program runs?
A. It displays the value of Number on the screen
B. It waits for the user to type a value and stores it in Number ✓
INPUT stores what the user types. Displaying a value is the job of OUTPUT.

Match the Pairs

INPUT Number → Waits for the user to type a value 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 with OUTPUT before asking for a value with INPUT → OUTPUT "Enter a number" INPUT Number
Display several items on one line by separating them with commas → OUTPUT "Average is ", Average
INPUT "Enter a number" → INPUT must be followed by a variable name, not a message. Use OUTPUT for the message, then INPUT Number to store the value.
OUTPUT "Total is " Total → The items are not separated by a comma. It should be OUTPUT "Total is ", Total.

Key Term

INPUT and OUTPUT
INPUT stores a value the user types into a variable. OUTPUT displays a message or value on screen. Show several items by separating them with commas.

Fill in the Blanks

1. OUTPUT "Total is ", Total
Hint: Type the keyword that displays a message and a value on screen.
2. INPUT Number
Hint: Type the keyword that stores a value typed by the user in a variable.
3. OUTPUT "Enter a number" INPUT Number OUTPUT "You typed ", Number
Hint: Type the variable that stores the user's value, which is displayed on the last line.
4. INPUT Price OUTPUT "Price is ", Price
Hint: Type the variable name whose stored value is shown after the message.
5. OUTPUT "Enter your age" INPUT Age
Hint: Type the keyword that shows a prompt to the user before they type a value.

Spot the Error

Question 1
A DECLARE Number : INTEGER
B INPUT 5
C OUTPUT "You typed ", Number
Line B — INPUT must be followed by a variable name that will store the typed value. You cannot input into the value 5. It should be INPUT Number.
Question 2
A DECLARE Total : INTEGER
B Total <- 10 + 5
C OUTPUT "Total is " Total
Line C — When OUTPUT shows several items, they must be separated by commas. A comma is missing after the message. It should be OUTPUT "Total is ", Total.
Question 3
A OUTPUT Enter your age
B INPUT Age
C OUTPUT "Age is ", Age
Line A — A message to display must be written in double quotes. Without them the words look like variable names. It should be OUTPUT "Enter your age".
Question 4
A OUTPUT "Enter a number"
B INPUT "Num"
C OUTPUT "Double is ", Num * 2
Line B — The variable name after INPUT must not be in quotes. Quotes make it a piece of text, not a variable that can store the value. It should be INPUT Num.
Question 5
A DECLARE Name : STRING
B INPUT Name
C OUTPUT "Hello ", "Name"
Line C — Putting Name in quotes outputs the word Name, not the value the user typed. A variable must be written without quotes: OUTPUT "Hello ", Name.

Student with a class code? Join your class →