Computer Science (AS & A Level) · Oct / Nov 2023 · Paper 41 · Question 1
9618
As printed in the paper
The question as text
This iterative pseudocode algorithm for the function IterativeVowels() takes a string as a parameter and counts the number of lower-case vowels in this string. The vowels are the letters a, e, i, o and u. FUNCTION IterativeVowels(Value : STRING) RETURNS INTEGER DECLARE Total : INTEGER DECLARE LengthString : INTEGER DECLARE FirstCharacter : CHAR Total ← 0 LengthString ← LENGTH(Value) FOR X ← 0 TO LengthString - 1 FirstCharacter ← MID(Value, 0, 1) IF FirstCharacter = 'a' OR FirstCharacter = 'e' OR FirstCharacter = 'i' OR FirstCharacter = 'o' OR FirstCharacter = 'u' THEN Total ← Total + 1 ENDIF Value ← MID(Value, 1, LENGTH(Value)-1) NEXT X RETURN Total ENDFUNCTION The pseudocode function MID(X, Y, Z) returns Z number of characters from string X, starting at the character in position Y. The first character in a string is in position 0, for example: MID("computer", 0, 3) returns "com" The pseudocode function LENGTH(X) returns the number of characters in the string X, for example: LENGTH("computer") returns 8
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
1(a)(i)[5]
1(a)(ii)[2]
1(a)(iii)[1]
1(b)(i)[6]
1(b)(ii)[1]
1(b)(iii)[1]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

