Skip to content

Course home

Constructs

Constructs

EasyMedium
1234567891011121314
Question 11

A smart sensor records the water level variations of a river relative to its baseline (in centimeters) every hour over an 8-hour monitoring window.

  • A value of 0 is recorded if the water is exactly at baseline level.
  • A negative value is recorded if the water level is below baseline.
  • A positive value is recorded if the water level is above baseline.

The algorithm in Figure 1 has been created to count and output how many times the river level exceeded a specific threshold.

Figure 1

SET levels TO [12, -4, 0, 8, -2, 15, 30, -1]
SET warning_count TO 0
SET index TO 0

WHILE index < LENGTH(levels) DO
    IF levels[index] > 10 THEN
        SET warning_count TO warning_count + 1
    END IF
    SET index TO index + 1
END WHILE

SEND "High levels recorded: " & warning_count TO DISPLAY

Identify the type of iteration construct used in Figure 1.

A

Post-conditioned loop

B

Count-controlled loop

C

Infinite loop

D

Pre-conditioned loop

Markscheme

Constructs Questions

  1. IGCSE
  2. /Computer Science
  3. /Constructs

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

Question bank