Topic 8 Β· Programming Β· 8.3

Input and Output Explained Simply

Programs need a way to receive data and a way to communicate results. Input sends data into a program. Output sends information back to the user.

Invitation

How does a program communicate with a user?

A program cannot solve a useful problem unless it can receive data or display a result.

When you type your name, choose a menu option or enter a score, you are giving the program input. When the program displays a greeting, result or message, it is producing output.

Input goes in. Output comes out.
Figure 1
The basic direction of data
User enters data
↓ INPUT
Program processes data
↓ OUTPUT
User sees the result
Big Idea

Input and output connect the program to the outside world

Input is data supplied to a program. It may come from a keyboard, sensor, file or another system.

Output is information produced by a program. It may appear on a screen, be printed, saved to a file or sent to another device.

In pseudocode, INPUT receives data and OUTPUT displays or produces data.
Figure 2
Input, process, output
INPUT: 8 and 4
↓
PROCESS: 8 + 4
↓
OUTPUT: 12
FutureLogic Bridge

A computer program is like a receptionist

Imagine arriving at a hotel. You tell the receptionist your name and booking details. That is input.

The receptionist checks the information and replies, β€œYour room is 214.” That reply is output.

A program works in the same way. It receives information, processes it and gives a useful response.

You speak to the receptionist β†’ input. The receptionist replies β†’ output.
Figure 3
The receptionist bridge
β€œMy name is Sam.”
↓ INPUT
Booking checked
↓ OUTPUT
β€œYour room is 214.”
Worked Example

Ask for a name and display a greeting

The program first asks the user to enter a name. The input is stored in the variable Name. The program then uses that value in its output.

PseudocodeInput and output
OUTPUT("Enter your name")
INPUT Name
OUTPUT("Hello ", Name)

What happens?

The user types Mark. The value is stored in Name. The program then displays:

Hello Mark
Read the Flow

Follow the data step by step

1The program displays a prompt.
2The user enters data.
3The data is stored in a variable.
4The program processes the value.
5The program produces output.
6The user sees the result.
Exam Tip

Separate the data from the device

In programming, input means the data entering the program. A keyboard is an input device, but the letters typed are the input data.

Use precise language: β€œThe user enters their age as input, and the program stores it in the variable Age.”

When writing pseudocode, make sure input is stored somewhere. Write INPUT Age, not just INPUT.

Common Mistake

β€œThe keyboard is the input.”

The keyboard is the device used to enter data. The input itself is the data typed by the user.

Incorrect answer: β€œThe keyboard is the input.”
Correct answer: β€œThe keyboard is an input device. The name typed by the user is the input data.”
Figure 4
Device versus data
Keyboard β†’ Input device
β‰ 
β€œMark” β†’ Input data
Summary

What should you remember?

1Input is data supplied to a program.
2Output is information produced by a program.
3Input is usually stored before it is processed.
Think of a receptionist: receive the details, process them, then give a response.