A function MakeString() will: 1. take two parameters: • a count as an integer • a character 2. generate a string of length equal to the count, made up of the character 3. return the string generated, or return "ERROR" if the count is less than 1. For example, the function call: MakeString(3, 'Z') will return the string "ZZZ"
- Write pseudocode for function MakeString().[6]
Mark scheme
Marking points from the official mark scheme (May/June 2023). The mark or mark type is shown in brackets.
- [6] FUNCTION MakeString(Count : INTEGER, AChar : CHAR) RETURNS STRING
- [6] DECLARE MyString : STRING
- [6] DECLARE Index : INTEGER
- [6] IF Count < 1 THEN
- [6] MyString ← "ERROR"
- [6] ELSE
- [6] MyString ← ""
- [6] FOR Index ← 1 TO Count
- [6] MyString ← MyString & AChar
- [6] NEXT Index
- [6] ENDIF
- [6] RETURN MyString
- [6] ENDFUNCTION
- [6] MP1 Function heading and end including parameters and return type
- [6] MP2 Declaration of locals Index and MyString
- [6] MP3 Test for Count < 1 and if true, assign "ERROR" to MyString / Immediate RETURN
- [6] MP4 Loop for Count iterations
- [6] MP5 Use of concatenate – must have been initialised in a loop
- [6] MP6 Return STRING (correctly in both cases)
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 →