Skip to content
MathsGenie logo
Open app

Course home

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

Develop code

EasyMediumHard
123456789101112131415161718192021222324
Question 8

An algorithm is designed to count the number of warm and cold days recorded in a greenhouse. Temperatures of 18 degrees Celsius and above are classified as warm, while temperatures below 18 are classified as cold.

There are four errors in the pseudocode shown in Figure 1.

Figure 1

LinePseudocode
01
02SET temps TO [18, 22, 14, 25, 12, 19, 15]
03
04SET warm TO 0
05SET cold TO 0
06SET index TO 0
07
08WHILE NOT (index > LENGTH(temps)) DO
09
10IF temps[index] >= 18 THEN
11SET warm TO temps[index]
12ELSE
13IF temps[index] < 18 THEN
14SET cold TO cold + 1
15END IF
16END IF
17
18SET index TO index + 1
19
20END WHILE
21
22SEND "Cold days: " & cold TO DISPLAY
23SEND "Warm days: " & warm TO DISPLAY

Write the correct code for line 11.

[1]

Develop code Questions

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