A program contains a global 1D array Data with 100 elements of type INTEGER. The program contains a function Process() expressed in pseudocode as follows: FUNCTION Process(Number : INTEGER, Label : STRING) RETURNS STRING DECLARE Index, Count : INTEGER DECLARE ReturnValue : STRING Count ← INT(100 / Number) Index ← Data [Number] CASE OF (Index MOD 2) 0 : ReturnValue ← TO_UPPER(RIGHT(Label, Count)) 1 : ReturnValue ← "****" ENDCASE RETURN RetVal ENDFUNCTION
- (a)Run-time errors can be generated in different ways. For example, a run-time error will be generated if a function is called with invalid parameters. The pseudocode contains three statements that could generate a run-time error. Write the three statements and explain how each could generate a run-time error. Statement 1 Explanation Statement 2 Explanation Statement 3 Explanation[3]
- (b)One type of run-time error can cause a program to stop responding ('freezing'). Identify a particular type of programming construct that can generate this type of error and explain why it occurs. Construct Explanation[2]
- (c)The function Process() contains a selection construct using a CASE structure. Write pseudocode using a single selection construct with the same functionality without using a CASE structure.[2]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [1] Statement 1: Count← INT(100 / Number)
- [1] Explanation: Number could be zero (giving a divide by zero)
- [1] Statement 2: Index ← Data [Number]
- [1] Explanation: Value Number could be outside the range of array indices
- [1] Statement 3: ReturnValue ← TO_UPPER(RIGHT(Label, Count))
- [1] Explanation: Number to extract may be too big / negative / out of range for use in the RIGHT function // Label has insufficient characters
- [1] Construct: A (pre/post) conditional loop
- [1] Explanation: The terminating condition is never satisfied
- [1] IF Index Mod 2 = O THEN
- [1] ReturnValue ← TO_UPPER(RIGHT(Label, Count))
- [1] ELSE
- [1] ReturnValue ← "****"
- [1] ENDIF
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 →