An incomplete algorithm has been written in pseudocode to count the number of values stored in an array and to find their average. Values have been stored in the array starting at A[1] All the values to be counted are non-zero. A value of zero in the array indicates there are no more values stored. 01 DECLARE A : ARRAY[1:50] OF INTEGER 02 DECLARE C : INTEGER 03 DECLARE W : INTEGER 04 DECLARE X : INTEGER 05 W ← 0 06 C ← 07 WHILE A[C] <> 0 08 09 C ← C + 1 10 ENDWHILE 11 X ←
- (a)Complete the given pseudocode algorithm.[3]
- (b)Write pseudocode to display, with suitable messages: • the number of values stored in the array • the average of those values stored.[3]
- (c)Meaningful identifiers have not been used in this algorithm. Suggest suitable meaningful identifiers for: The array A The variables C X W[3]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [3] (a) One mark for each point
- (a) 06 C ← 1
- (a) 08 W ← W + A[C]
- (a) 11 X ← W / (C – 1) // ROUND(W / (C – 1),0)
- [3] (b) One mark for outputting X
- (b) One mark for outputting C – 1
- (b) One mark for suitable messages
- (b) Example: 12 OUTPUT "Number of values stored in the array is ", C – 1 13 OUTPUT "Average of non-zero elements in the array is ", X
- [3] (c) One mark for meaningful identifier for the array
- (c) A Values
- (c) Two marks for 3 meaningful identifiers for the variables
- (c) or
- (c) One mark for 1 to 2 meaningful identifiers for the variables
- (c) C Index
- (c) X Average
- (c) W Total
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 →