A programming language has string functions equivalent to those given in the insert. The language includes a LEFT() and a RIGHT() function, but it does not have a MID() function.
- (a)Write pseudocode for an algorithm to implement your own version of the MID() function which will operate in the same way as that shown in the insert. Do not use the MID () function given in the insert, but you may use any of the other functions. Assume that the values passed to the function will be correct.[4]
- (b)The values passed to your MID () function in part (a) need to be validated. Assume that the values are of the correct data type. State two checks that could be applied to the values passed to the function. 1 2[2]
Mark scheme
Marking points from the official mark scheme (May/June 2022). The mark or mark type is shown in brackets.
- [4] Marks as follows:
- 1 Function heading and ending including parameters and return type
- 2 Correct use of one substring functions
- 3 Correct use of both substring functions (in correct sequence)
- 4 Return substring after a reasonable attempt
- [2] One mark per point
- Check that:
- • Start and/or Num are >= 1 // positive
- • Length of InString is "sufficient" for required operation
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 →