Skip to main content
A-LevelComputer ScienceProgramming9618/41 · Oct/Nov 2023 · Q116 Marks

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

  1. (a)(i)Write program code for the function IterativeVowels(). Save your program as Question1_N23. Copy and paste the program code into part 1(a)(i) in the evidence document.[5]
  2. (a)(ii)Write program code to call the function IterativeVowels() with the parameter "house" from the main program. Output the return value. Save your program. Copy and paste the program code into part 1(a)(ii) in the evidence document.[2]
  3. (a)(iii)Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 1(a)(iii) in the evidence document.[1]
  4. (b)(i)Rewrite the function IterativeVowels() as a recursive function with the identifier RecursiveVowels(). Save your program. Copy and paste the program code into part 1(b)(i) in the evidence document.[6]
  5. (b)(ii)Write program code to call the function RecursiveVowels() with the parameter "imagine" from the main program. Output the return value. Save your program. Copy and paste the program code into part 1(b)(ii) in the evidence document.[1]
  6. (b)(iii)Test your program. Take a screenshot of the output. Save your program. Copy and paste the screenshot into part 1(b)(iii) in the evidence document.[1]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.

  1. [5] One mark each to max 5
  2. • Function header (and end where appropriate) taking one string parameter
  3. • Calculating length of parameter string
  4. • Looping correct number of times
  5. • Checking the first character against all vowels
  6. • Accessing the remainder of the string
  7. Remainder of function correct with nothing extra i.e. totalling, must match structure of given algorithm
  8. [2] One mark each
  9. • Calling the function with "house"
  10. • Outputting the return value
  11. [1] One mark for screenshot outputting 3
  12. [6] One mark each
  13. • Recursive call
  14. • Function header (and end where appropriate) taking string parameter (returning integer where given)
  15. • Base case checking (length is 0) and returning 0
  16. • Extracting first character and checking if a vowel
  17. • ... if it is a vowel, returning 1 + recursive call with 1 less character
  18. • ... if not a vowel, return recursive call with 1 less character
  19. [1] One mark for calling recursive function with "imagine" and outputting return value
  20. [1] One mark for screenshot showing 4

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Programming, A-Level Computer Science (syllabus 9618). Structured question, 16 marks.
Source
A-Level Computer Science, Oct/Nov 2023 Paper 4 Variant 1, question 1.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep