Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

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]

Develop code Questions

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