Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
Question 5

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?

A

Line number 2

B

Line number 4

C

Line number 11

D

Line number 12

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