Input and Output
How a program reads input from the user and outputs data and results, and why input arrives as a string that must be converted to a number before it can be used in a calculation.
Get the method right under pressure
Free interactive practice on the steps that lose marks under exam pressure.
Start revising freeWhat you'll cover
Talking to the user
A useful program takes something in from the user and gives something back. Reading a value the user types is input, and showing a value or a result is output. There is one trap that catches beginners: what the user types always arrives as text, so a number must be converted before you can do sums with it. This module covers input, output and that conversion.
Input and output words
Learn these before you trace a program.
Text against number
The same typed digits behave differently before and after conversion.
Read it, convert it, use it
For any input question follow three steps. Read the value the user types, remember it arrives as a string, and convert it to a number before any calculation. If you add two strings such as the text 5 and the text 3 you get 53, not 8, so convert first. Then output the result clearly so the user can read it.
Match the term
- input
- output
- string
- conversion
- a value read in from the user
- a value shown to the user
- text made of characters
- changing text into a number
Match the step
- reading the age a user types
- turning that text into a number
- adding the numbers together
- displaying the total on screen
- this is the input step
- this is the conversion step
- this is the calculation step
- this is the output step
What form is input?
When a user types a value at the keyboard, what form does the program first receive it in?
- As a string of text characters.
- Always as a ready-to-use number.
- As nothing until you calculate.
- As output.
Good input and output
Select the TWO statements that are correct.
- Convert a numeric input before doing arithmetic
- Output the result so the user can read it
- You can add two text inputs to get their total
- A calculation is useless without any input at all
Add the converted inputs
A user types 5 and then 3. After the program converts both from strings into numbers, it adds them. What total does it output?
Order the program
Put the steps of a program that adds two typed numbers in order, earliest first.
- Read the two values the user types
- Convert both from text to numbers
- Add the two numbers
- Output the total
Complete the rules
A value read in from the user is called _____, and a value shown back is called _____. Typed values first arrive as a _____, so a numeric one must be turned into a number by _____ before any arithmetic.
Spot the output
Tap the TWO actions that are output, showing something to the user.
- printing the answer on screen
- displaying a welcome message
- reading a number the user types
- waiting for the user to enter a name
Read the program
Read each case and choose the best answer.
- A program adds the text 5 and the text 3 without converting them. What does it produce?
- A program needs the user to enter their age and then calculates with it. What must it do first?
- A finished calculation gives a total, but the user never sees it. What is missing?
Explain input and output
Explain how a program reads input and shows output, and why a typed number must be converted before it is used.
- Say what input and output each mean
- Explain why input needs converting before arithmetic
- Describe what happens if two text values are added without converting