Question 1
2 marksA student wrote this line in an algorithm for a speed camera:
IF Speed is more than the speed limit THEN OUTPUT "Fine"
The speed limit is stored in the constant Limit.
Explain why this line would not be accepted as pseudocode, and rewrite it as precise Cambridge pseudocode.
Model answer
The condition is written in English instead of using a relational operator, and it does not use the identifier Limit, so it is not precise.
IF Speed > Limit
THEN
OUTPUT "Fine"
ENDIF
Explanation
Paper 2 algorithms must be precise: comparisons are written with operators such as >, < and = and use the actual identifiers. A phrase like 'is more than the speed limit' could be read in different ways and could not be turned directly into program code. Every IF also needs THEN and a closing ENDIF.
Mark scheme
-
1 mark
The condition is written in English words ('is more than the speed limit'), so it is not precise / does not use a relational operator / does not use the identifier Limit
-
1 mark
Correct pseudocode using the > operator and the identifier Limit, with THEN and ENDIF, e.g. IF Speed > Limit THEN OUTPUT "Fine" ENDIF
accept the IF statement laid out over several lines; do not accept >= (more than means >); do not accept a missing ENDIF