A global 1D array Data contains 100 elements of type integer. A function Check() will: • total the element values in odd index locations (1, 3, 5 ... 97, 99) • total the element values in even index locations (2, 4, 6 ... 98, 100) • return one of three strings 'Odd', 'Even' or 'Same' to indicate which total is the greater, or whether the totals are the same. Write pseudocode for the function Check().
- A global 1D array Data contains 100 elements of type integer. A function Check() will: • total the element values in odd index locations (1, 3, 5 ... 97, 99) • total the element values in even index locations (2, 4, 6 ... 98, 100) • return one of three strings 'Odd', 'Even' or 'Same' to indicate which total is the greater, or whether the totals are the same. Write pseudocode for the function Check().[6]
Mark scheme
Marking points from the official mark scheme (May/June 2024). The mark or mark type is shown in brackets.
- [6] Example:
- FUNCTION Check() RETURNS STRING
- DECLARE Odd, Even, Index : INTEGER
- Odd ← 0
- Even ← 0
- FOR Index ← 1 TO 100
- IF Index MOD 2 = 0 THEN
- Even ← Even + Data[Index]
- ELSE
- Odd ← Odd + Data[Index]
- ENDIF
- NEXT Index
- ENDFUNCTION
- Mark as follows:
- 1. Function heading, ending and return type
- 2. Declare local variables Odd, Even and Index as integers
- 3. Initialise Odd and Even
- 4. Loop for 100 iterations // through array
- 5. Sum Odd and Even element values in a loop
- 6. Compare Odd and Even after the loop and Return appropriate 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 →