Skip to main content
A-LevelComputer ScienceFurther programming9618/21 · Oct/Nov 2023 · Q69 Marks

6 The pseudocode OUTPUT command starts each output on a new line. (a) A new procedure MyOutput() will take a string and a Boolean parameter. MyOutput() may be called repeatedly and will use concatenation to build a string using a global variable MyString, up to a maximum length of 255 characters. MyString will be output in either of these two cases: 1. The Boolean parameter value is TRUE 2. The resulting string (after concatenation) would be longer than 255 characters. If MyString is not output, the string is concatenated with MyString. For example, the calls to MyOutput() given below would result in the output as shown: MyOutput("Hello ", FALSE) MyOutput("ginger ", FALSE) MyOutput("cat", TRUE) MyOutput("How are you?", TRUE) Resulting output: Hello ginger cat How are you? Notes: : MyString is initialised to an empty string before MyOutput () is called for the first time. No string passed to MyOutput () will be longer than 255 characters.

  1. (a)Write pseudocode for MyOutput().[7]
  2. (b)The design of the procedure given in part (a) is modified and MyString is changed from a global to a local variable declared in MyOutput(). When the modified procedure is converted into program code, it does not work as expected. Explain why it does not work as expected.[2]

Mark scheme

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

  1. [1] Procedure heading `PROCEDURE MyOutput(NewString : STRING, EOL : BOOLEAN)` and `ENDPROCEDURE`
  2. [1] Calculate potential new length (e.g., `LENGTH(MyString) + LENGTH(NewString)`)
  3. [1] Check if potential new length > 255 (e.g., `IF LENGTH(MyString) + LENGTH(NewString) > 255 THEN`)
  4. [1] If length > 255, then `OUTPUT MyString` (the old `MyString`) and `MyString ← NewString`
  5. [1] Else (`MyString ← MyString & NewString`)
  6. [1] Check `EOL` parameter (e.g., `IF EOL = TRUE THEN`)
  7. [1] If `EOL` is TRUE, then `OUTPUT MyString` and `MyString ← ""`
  8. [1] A new (instance of) variable MyString is created each time the procedure is called / executed
  9. [1] So the previous contents are lost / MyString is re-initialised to empty string

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, 9 marks.
Source
A-Level Computer Science, Oct/Nov 2023 Paper 2 Variant 1, question 6.

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