An algorithm has been written in pseudocode to input the names and marks of 35 students. The algorithm stores the names and marks in two arrays Name [ ] and Mark []. The highest mark awarded is found and the number of students with that mark is counted. Both of these values are output. 01 HighestMark ← 100 02 HighestMarkStudents ← 0 03 FOR Count ← 1 ΤΟ 35 04 OUTPUT "Please enter student name" 05 INPUT Name [Count] 06 OUTPUT "Please enter student mark" 07 INPUT Mark [Counter] 08 IF Mark [Count] = HighestMark 09 THEN 10 HighestMarkStudents ← HighestMarkStudents 1 11 ENDIF 12 IF Mark [Count] > HighestMark 13 THEN 14 Mark [Count] ← HighestMark 15 HighestMarkStudents ← 1 16 ENDIF 17 NEXT Count 18 OUTPUT "There are ", HighestMarkStudents," with the highest mark of ", HighestMark
- (a)Give line numbers where the four errors are to be found in the pseudocode. Suggest a correction for each error. Error 1 line number Correction Error 2 line number Correction Error 3 line number Correction Error 4 line number Correction[4]
- (b)Explain how you could extend the algorithm to also find the lowest mark awarded, count the number of students with that mark, and output both these values.[6]
Mark scheme
Marking points from the official mark scheme (May/June 2020). The mark or mark type is shown in brackets.
- [1] Line 1 error: HighestMark ← 100; Correction: HighestMark ← 0
- [1] Line 7 error: INPUT Mark [Counter]; Correction: INPUT Mark [Count]
- [1] Line 10 error: HighestMarkStudents ← HighestMarkStudents 1; Correction: HighestMarkStudents ← HighestMarkStudents + 1
- [1] Line 14 error: Mark [Count] ← HighestMark; Correction: HighestMark ← Mark[Count]
- [1] Add variable LowestMark
- [1] Set LowestMark to a high value (e.g., 100)
- [1] Add variable LowestMarkStudents
- [1] Set LowestMarkStudents to zero
- [1] Check if Mark [Count] = LowestMark
- [1] If true, add 1 to LowestMarkStudents
- [1] Check if Mark [Count] < LowestMark
- [1] If true, set LowestMarkStudents to 1 and set LowestMark to Mark [Count]
- [1] Add extra output statement for lowest mark and count
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 →