Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
Question 7

An algorithm is designed to display a student's marks in four different school subjects. Each subject has two exam scores stored in a single list. The algorithm contains an error.

Figure 1 shows the pseudocode for this algorithm.

1  subjects ← ['Maths', 'English', 'Science', 'History']
2  grades ← [85, 90, 72, 78, 92, 88, 64, 70]
3  total ← 0
4  FOR i ← 0 TO 2
5      sub ← subjects[i]
6      OUTPUT 'Subject: ', sub
7      FOR j ← 0 TO 1
8          OUTPUT 'Exam: ', j + 1
9          mark ← grades[i * 2 + j]
10         OUTPUT mark
11         total ← total + mark
12     ENDFOR
13 ENDFOR

How could the error in the algorithm in Figure 1 be corrected?

A

Change line number 3 to: total←1\text{total} \leftarrow 1total←1

B

Change line number 4 to: FOR i←0 TO 3\text{FOR } i \leftarrow 0 \text{ TO } 3FOR i←0 TO 3

C

Change line number 7 to: FOR j←0 TO 2\text{FOR } j \leftarrow 0 \text{ TO } 2FOR j←0 TO 2

D

Change line number 9 to: mark←grades[j×4+i]\text{mark} \leftarrow \text{grades}[j \times 4 + i]mark←grades[j×4+i]

Markscheme

Representing algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms

208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank