Three ways to express an algorithm
Structured English, pseudocode, flowcharts — pick the right one for the audience.
An algorithm can be written in three standard ways. They convey the same meaning at different levels of formality.
Structured English. Plain English with structured indentation and key phrases.
Repeat for each student: Read the student's mark. If the mark is at least 40, add 1 to PassCount. Output PassCount.
Use when: explaining the algorithm to non-programmers.
Pseudocode. English-like keywords following a defined convention. Cambridge has its own conventions (INPUT, OUTPUT, IF...THEN...ELSE...ENDIF, FOR...NEXT, WHILE...ENDWHILE, REPEAT...UNTIL).
PassCount ← 0
FOR Counter ← 1 TO N
INPUT Mark
IF Mark >= 40 THEN
PassCount ← PassCount + 1
ENDIF
NEXT Counter
OUTPUT PassCount
Use when: communicating to programmers; about to translate into code.
Flowcharts. Diagrams with standard shapes connected by arrows. Use when: visualising flow with branches and loops; documenting for visual learners.
Cambridge tip. Pseudocode in 0478 follows specific conventions. Use Cambridge keywords; don't write Python or Java.
- Structured English for non-programmers.
- Pseudocode for programmers.
- Flowcharts for visual flow with branches.