Use a range of recognised methods to design, construct, test and evaluate a solution to a problem, covering both the computer‑systems context and the programming‑logic context required by the syllabus.
-13 → 11110011 in 8‑bit two’s‑complement).| Method | Purpose | Typical Pseudocode Pattern |
|---|---|---|
| Totalling / Counting | Accumulate a sum or a count while iterating. | SET total←0; REPEAT … SET total←total+value … END REPEAT |
| Maximum / Minimum (Linear Search) | Find the extreme value in a list. | SET max←‑∞; REPEAT … IF value>max THEN SET max←value END IF … END REPEAT |
| Average | Mean = total / count (use floating‑point if required). | SET avg←total / count |
| Sorting (Bubble Sort) | Arrange data in ascending/descending order. | FOR i←1 TO n‑1 REPEAT FOR j←1 TO n‑i IF a[j]>a[j+1] THEN SWAP a[j],a[j+1] END IF END REPEAT END FOR |
| Search (Linear / Binary) | Locate a specific value. | Linear: REPEAT … IF a[i]=key THEN FOUND←TRUE END IF … END REPEAT Binary: WHILE low≤high … |

| Element | Convention |
|---|---|
| Keywords | Upper‑case (READ, OUTPUT, IF, THEN, ELSE, END IF, REPEAT, UNTIL, WHILE, END WHILE, FOR, END FOR) |
| Indentation | Two spaces per block level; no tabs. |
| Meta‑variables | Italicised or enclosed in <> (e.g. <score>) to show placeholders. |
| Line numbers | Optional but useful for discussion; format “1.”, “2.” … |
| Comments | Start with // or REM. Keep them brief and on their own line. |
| Assignments | Use the arrow symbol ← (or = if arrow unavailable). |
| Loop controls | REPEAT … UNTIL condition or FOR i FROM 1 TO n … END FOR. |
1. SET count ← 0 2. SET total ← 0 3. SET highest ← -1 4. SET lowest ← 101 5. REPEAT 6. READ <score> 7. IF <score> < 0 THEN 8. EXIT REPEAT 9. END IF 10. IF <score> > 100 OR <score> < 0 THEN 11. OUTPUT "Invalid – enter 0‑100" 12. CONTINUE REPEAT 13. END IF 14. SET count ← count + 1 15. SET total ← total + <score> 16. IF <score> > highest THEN SET highest ← <score> END IF 17. IF <score> < lowest THEN SET lowest ← <score> END IF 18. END REPEAT 19. IF count = 0 THEN 20. OUTPUT "No scores entered." 21. ELSE 22. SET average ← total / count 23. OUTPUT "Count:", count, 24. "Highest:", highest, 25. "Lowest:", lowest, 26. "Average:", ROUND(average,2) 27. END IF

| Condition | Score < 0 | 0 ≤ Score ≤ 100 | Score > 100 or < 0 (invalid) |
|---|---|---|---|
| Action | Terminate loop | Update count, total, highest, lowest | Display error, repeat input |
BEGIN
SET count = 0, total = 0, highest = -1, lowest = 101
REPEAT
READ score
IF score < 0 THEN EXIT REPEAT END IF
IF score > 100 OR score < 0 THEN
OUTPUT "Invalid score – must be 0‑100"
CONTINUE REPEAT
END IF
SET count = count + 1
SET total = total + score
IF score > highest THEN SET highest = score END IF
IF score < lowest THEN SET lowest = score END IF
END REPEAT
IF count > 0 THEN
SET average = total / count
OUTPUT count, highest, lowest, average
ELSE
OUTPUT "No scores entered."
END IF
END
| Aspect | Validation (Input Checking) | Verification (Output Checking) |
|---|---|---|
| Purpose | Ensure data entered meets type, range, length or format requirements before it is processed. | Confirm that the algorithm produces the expected results for given inputs. |
| Typical Checks | Range (0 ≤ score ≤ 100), type (numeric), termination condition (negative number). | Trace tables, boundary‑value testing, comparison with hand‑calculated results. |
| When Performed | During input stage, before any calculation. | After the algorithm has run – during testing/debugging. |
Write a program that reads a list of integer scores (0‑100) entered by the user, terminated by a negative number. The program must output:
1. SET count ← 0 2. SET total ← 0 3. SET highest ← -1 4. SET lowest ← 101 5. REPEAT 6. READ <score> 7. IF <score> < 0 THEN 8. EXIT REPEAT 9. END IF 10. IF <score> > 100 OR <score> < 0 THEN 11. OUTPUT "Invalid – enter 0‑100" 12. CONTINUE REPEAT 13. END IF 14. SET count ← count + 1 15. SET total ← total + <score> 16. IF <score> > highest THEN SET highest ← <score> END IF 17. IF <score> < lowest THEN SET lowest ← <score> END IF 18. END REPEAT 19. IF count = 0 THEN 20. OUTPUT "No scores entered." 21. ELSE 22. SET average ← total / count 23. /* Extension – count scores above average */ 24. SET aboveAvg ← 0 25. REPEAT FOR i FROM 1 TO count 26. IF score[i] > average THEN SET aboveAvg ← aboveAvg + 1 END IF 27. END REPEAT 28. OUTPUT "Count:", count, 29. "Highest:", highest, 30. "Lowest:", lowest, 31. "Average:", ROUND(average,2), 32. "Above average:", aboveAvg 33. END IF
| Step | score (input) | count | total | highest | lowest |
|---|---|---|---|---|---|
| Start | – | 0 | 0 | -1 | 101 |
| 1 | 85 | 1 | 85 | 85 | 85 |
| 2 | 70 | 2 | 155 | 85 | 70 |
| 3 | 90 | 3 | 245 | 90 | 70 |
| 4 | -1 | 3 | 245 | 90 | 70 |
| Condition | Score < 0 | 0 ≤ Score ≤ 100 | Score > 100 or < 0 (invalid) |
|---|---|---|---|
| Action | Terminate loop | Update count, total, highest, lowest | Display error, repeat input |
| Criterion | What to Check |
|---|---|
| Correctness | All test cases (normal, boundary, error) produce the expected output; trace tables confirm logic. |
| Efficiency | Time = O(n) – single pass for totals and extremes; Space = O(1) – only a few scalar variables (or O(n) if storing the list for the extension). |
| Readability | Consistent indentation, meaningful variable names, comments for validation steps. |
| Maintainability | Algorithm is modular – each sub‑task could be placed in a separate function or procedure. |
| Compliance with Specification | All required outputs are produced; the optional “above‑average” count is clearly separated. |
“The algorithm is correct because it has been tested with normal data (85, 70, 90), boundary data (0, 100) and error data (‑5, 150). In each case the trace table matches the expected results, confirming the logic. It runs in linear time O(n) and uses only four integer variables, so it is efficient in both time and space. The use of uppercase keywords, two‑space indentation and clear variable names makes the pseudocode easy to read. All parts of the specification are met: the programme reports the count, highest, lowest and average, and the optional part correctly counts scores above the average. Therefore the solution fully satisfies the problem requirements.”
Modify the algorithm to count how many scores are above the calculated average and display this number. Two approaches are possible:
Both approaches should be evaluated for time and space efficiency using the checklist in Section 6.
Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.