Inputs, processes and outputs of an algorithm

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Inputs, processes and outputs of an algorithm

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. In the line INPUT Mark, what part of the algorithm is this?
A An input: data is read into the algorithm
B An output: a result is shown to the user
2. Which statement is an OUTPUT in an algorithm?
A Total ← Total + 1
B OUTPUT Total
3. Which line is a process?
A Average ← Total / 5
B INPUT Total
4. Is IF Score >= 50 THEN a process or an input?
A An input: it reads the score from the user
B A process: it makes a decision
5. Where is a value kept while the algorithm uses it between input and output?
A In a variable or an array
B In an OUTPUT statement

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1INPUT Mark AAn output: the algorithm displays a message and the value of Total to the user
2OUTPUT "Total: ", Total BThis is a process (counting stored in a variable), not an output. Nothing is shown to the user until an OUTPUT statement such as OUTPUT Count runs.
3A process: a calculation that works on the input data and stores the result in a variable CIF Mark >= 50 THEN
4A process: a decision that chooses what happens next depending on the input DThis is a process (a calculation stored in a variable), not an input. The input is the INPUT Mark statement that brings the value in.
5Inputs: Total ← Total + Mark ETotal ← Total + Mark
6Outputs: Count ← Count + 1 FAn input: the algorithm takes a value from the user and stores it in the variable Mark

Definitions

Input, process, output

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
_____ Price Total ← Price * 2 OUTPUT Total
2.
INPUT Price INPUT Qty Total ← Price _ Qty
3.
INPUT Mark __ Mark >= 50 THEN OUTPUT "Pass"
4.
INPUT Age NextAge ← Age + 1 ______ NextAge
5.
FOR Count ← 1 TO 3 INPUT Scores[_____] NEXT Count

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A INPUT Length
B INPUT Width
C Area = Length * Width
D OUTPUT Area
Question 2
A OUTPUT Mark
B IF Mark >= 50 THEN
C OUTPUT "Pass"
D ENDIF
Question 3
A INPUT Price
B INPUT Quantity
C Total ← Price * Qty
D OUTPUT Total
Question 4
A INPUT Cost
B Cost * 0.2 ← Tax
C Final ← Cost + Tax
D OUTPUT Final
Question 5
A DECLARE Marks : ARRAY[1:3] OF INTEGER
B FOR Count ← 1 TO 3
C INPUT Marks[Count]
D ENDFOR
E OUTPUT Marks[1]

Answer Key

Inputs, processes and outputs of an algorithm
Section A: Quick Questions
Q1
A — An input: data is read into the algorithm
Q2
B — OUTPUT Total
Q3
A — Average ← Total / 5
Q4
B — A process: it makes a decision
Q5
A — In a variable or an array
Section B: Match the Pairs
Q1
INPUT Mark → An input: the algorithm takes a value from the user and stores it in the variable Mark
Q2
OUTPUT "Total: ", Total → An output: the algorithm displays a message and the value of Total to the user
Q3
A process: a calculation that works on the input data and stores the result in a variable → Total ← Total + Mark
Q4
A process: a decision that chooses what happens next depending on the input → IF Mark >= 50 THEN
Q5
Inputs: Total ← Total + Mark → This is a process (a calculation stored in a variable), not an input. The input is the INPUT Mark statement that brings the value in.
Q6
Outputs: Count ← Count + 1 → This is a process (counting stored in a variable), not an output. Nothing is shown to the user until an OUTPUT statement such as OUTPUT Count runs.
Section C: Definitions
Q1
Input, process, output — Every algorithm takes INPUT data, carries out processes on it (calculations, decisions, storing in variables or arrays), then gives OUTPUT results.
Section D: Fill in the Blanks
Q1
INPUT Price Total ← Price * 2 OUTPUT Total
Q2
INPUT Price INPUT Qty Total ← Price * Qty
Q3
INPUT Mark IF Mark >= 50 THEN OUTPUT "Pass"
Q4
INPUT Age NextAge ← Age + 1 OUTPUT NextAge
Q5
FOR Count ← 1 TO 3 INPUT Scores[Count] NEXT Count
Section E: Spot the Error
Q1
C — The calculation stores its result in a variable, so it needs the assignment arrow. It should be Area ← Length * Width. A single = is used for comparison.
Q2
A — The algorithm needs Mark as its input. Line 1 should be INPUT Mark so the value is read in, not OUTPUT Mark, which would display a value that does not exist yet.
Q3
C — Qty was never input or declared. The process must use the input variable Quantity: Total ← Price * Quantity.
Q4
B — The variable being assigned to must be on the left of the arrow and the calculation on the right. It should be Tax ← Cost * 0.2.
Q5
D — A FOR loop in IGCSE pseudocode ends with NEXT followed by the loop variable, so line 4 should be NEXT Count. ENDFOR is not a pseudocode keyword.