Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
Question 7
Easy

An algorithm is used to control a smart heating system based on user mode selection and current temperature.

Figure 1 shows the pseudocode for this algorithm.

1      mode ← USERINPUT
2      IF mode = 'eco' THEN
3          target ← 18
4      ELSE IF mode = 'comfort' THEN
5          target ← 21
6      ELSE IF mode = 'boost' THEN
7          target ← 23
8      ELSE
9          OUTPUT 'invalid mode'
10     ENDIF
11     WHILE current_temp < target
12         IF current_temp < 15 THEN
13             ACTIVATE_HEATER('high')
14         ELSE
15             ACTIVATE_HEATER('low')
16         ENDIF
17         current_temp ← READ_SENSOR()
18     ENDWHILE

Which line number shows where iteration is first used in the algorithm shown in Figure 1?

Line number 2

Line number 4

Line number 11

Line number 12

Representing algorithms Questions

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