Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
Question 4

A sensor array tracks temperatures across a regional grid. The grid is represented by a 2D array, thermal_map, with 4 rows and 3 columns. The current temperature readings (in ∘C^\circ\text{C}∘C) are shown in the table below:

Row \ Column012
0234118
1463245
2192415
3451230

The following algorithm is used to locate thermal anomalies (temperatures of 45∘C45^\circ\text{C}45∘C or higher):

max_row = -1
max_col = -1
for r from 0 to 3
    for c from 0 to 2
        if get_temp(r, c) >= 45 then
            max_row = r
            max_col = c
        endif
    endfor
endfor

Which of the following statements about the execution of this algorithm is correct?

A

The final value of the variable max_col is 222.

B

The outer loop's block (the inner loop) is executed a total of 121212 times.

C

The conditional expression get_temp(r, c) >= 45 is evaluated exactly 121212 times.

D

The assignment statements inside the if block are executed exactly 222 times.

Markscheme

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts

298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank