Write pseudocode that contains input, process and output

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level Computer Science 9618 – Algorithms: Writing Pseudocode with Input, Process, Output

Topic 9.2 – Algorithms

Learning Objective

Students will be able to write clear and structured pseudocode that explicitly shows the three fundamental stages of an algorithm: input, process and output.

Why Separate Input, Process and Output?

  • Clarifies the purpose of each part of the algorithm.
  • Helps in debugging and testing.
  • Facilitates translation into any programming language.

Standard Pseudocode Conventions

  1. Use all‑caps for keywords such as INPUT, OUTPUT, IF, ELSE, FOR, WHILE.
  2. Indent statements to show structure.
  3. Comment lines start with # or //.
  4. Variable names should be meaningful and use camelCase or snake_case consistently.

Structure of a Complete Algorithm

A complete algorithm can be divided into three sections, as shown in the table below.

SectionPurposeTypical Keywords
InputObtain data from the user or another system.INPUT, READ
ProcessPerform calculations, decisions and loops.IF, FOR, WHILE, SET, CALCULATE
OutputPresent the result to the user or another system.OUTPUT, DISPLAY, PRINT

Example 1 – Converting Celsius to Fahrenheit

This example demonstrates a simple algorithm that reads a temperature in Celsius, converts it to Fahrenheit, and displays the result.

# Algorithm: Celsius to Fahrenheit

INPUT celsius

SET fahrenheit ← (9/5) * celsius + 32

OUTPUT fahrenheit

Explanation:

  • INPUT celsius – reads a numeric value from the user.
  • SET fahrenheit ← (9/5) * celsius + 32 – the process step using the conversion formula \$F = \frac{9}{5}C + 32\$.
  • OUTPUT fahrenheit – displays the converted temperature.

Example 2 – Finding the Maximum of Three Numbers

This algorithm shows the use of conditional statements within the process section.

# Algorithm: Maximum of three numbers

INPUT a, b, c

SET max ← a

IF b > max THEN

SET max ← b

ENDIF

IF c > max THEN

SET max ← c

ENDIF

OUTPUT max

Key points:

  • The INPUT line gathers three separate values.
  • The SET max ← a initializes the process.
  • Two IF statements compare the remaining numbers with the current max.
  • Finally, OUTPUT max presents the largest value.

Exercise – Write Pseudocode for a Simple Payroll Calculator

Students should produce pseudocode that:

  1. Inputs an employee’s name, hours worked (numeric) and hourly rate (numeric).
  2. Calculates gross pay as hoursWorked × hourlyRate.
  3. Applies a tax deduction of 20 % if gross pay exceeds $500.
  4. Outputs the employee’s name and net pay.

Suggested solution (students should attempt before viewing):

# Algorithm: Payroll Calculator

INPUT name, hoursWorked, hourlyRate

SET grossPay ← hoursWorked * hourlyRate

IF grossPay > 500 THEN

SET netPay ← grossPay * 0.80 # 20% tax deduction

ELSE

SET netPay ← grossPay

ENDIF

OUTPUT name, netPay

Common Pitfalls

  • Omitting the INPUT or OUTPUT statements – the algorithm becomes incomplete.
  • Mixing process calculations with input or output commands.
  • Using ambiguous variable names that hide the purpose of each step.

Summary

Every well‑structured algorithm should clearly separate the three stages:

  1. Input – acquire all required data.
  2. Process – perform the logical work.
  3. Output – deliver the results.

Following this pattern makes translation to actual code straightforward and improves readability.

Suggested diagram: Flowchart showing the Input → Process → Output sequence.