Question 1
1 markThe algorithm below is written in pseudo-code.
word ← USERINPUT
count ← 0
FOR ch IN word
IF ch = 'a' OR ch = 'e' OR ch = 'i' OR ch = 'o' OR ch = 'u' THEN
count ← count + 1
ENDIF
ENDFOR
OUTPUT countState the output when the user enters Aberdeen
Model answer
3
Explanation
The loop compares every character with the five lower-case vowels. In Aberdeen the three lower-case e's match, but the capital A does not, because 'A' and 'a' are different characters with different character codes. The common mistake is to answer 4 by counting the capital A.
Mark scheme
-
1 mark
3
Mark is for AO2 (apply). R. 4 (the capital A is not equal to 'a', so it is not counted). I. Quotation marks.