Skip to content

Course home

Develop code

Develop code

EasyMediumHard
123456789101112131415161718192021222324
Question 23

There are four errors in the pseudocode in Figure 2 which processes a list of parcel weights.

Write the correct pseudocode for line 25.

Figure 2

01
02SET weights TO [2.5, 0.8, 4.2, 1.0, 3.8, 0.4]
03
04SET light TO 0
05SET standard TO 0
06SET heavy TO 0
07SET index TO 0
08
09WHILE NOT (index > LENGTH(weights)) DO
10
11IF weights[index] < 1.0 THEN
12SET light TO light + 1
13ELSE
14IF weights[index] > 4.0 THEN
15SET heavy TO weights[index]
16ELSE
17SET standard TO standard + 1
18END IF
19END IF
20
21SET index TO index + 1
22END WHILE
23
24SEND "Light: " & light TO DISPLAY
25SEND "Total items processed: " & (light - heavy) TO DISPLAY
26SEND "Heavy: " & heavy TO DISPLAY
27
[1]
Markscheme

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code

62 exam-style questions on Edexcel IGCSE Computer Science Develop code. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank