Skip to main content
A-LevelComputer ScienceFurther programming9618/22 · May/June 2023 · Q46 Marks

A function GetNum() will: 1. take two parameters: a string and a character 2. count the number of times that the character occurs in the string 3. return the count. Any comparison between characters needs to be case sensitive. For example, character 'a' and character 'A' are not identical. Write pseudocode for function GetNum().

  1. Write pseudocode for function GetNum().[6]

Mark scheme

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

  1. [6] FUNCTION GetNum(ThisString : STRING, ThisChar : CHAR) RETURNS INTEGER DECLARE Index, Count : INTEGER Count ← 0 FOR Index ← 1 TO LENGTH(ThisString) IF MID(ThisString, Index, 1) = ThisChar THEN Count ← Count + 1 ENDIF NEXT Index RETURN Count ENDFUNCTION Mark as follows: 1 Function heading and end, including parameters and return type 2 Declare local Integers for Index and Count 3 Loop for length of ThisString 4 Extract a character and compare with parameter in a loop 5 Increment Count if match in a loop 6 Return Count after loop

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
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 6 marks.
Source
A-Level Computer Science, May/June 2023 Paper 2 Variant 2, question 4.

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