An automated search-and-rescue drone uses an infrared sensor to scan a forest, representing the area as a 4×4 4 \times 4\,4×4 grid of temperature readings stored in a 2D array named thermal_grid. A specific reading of 100 indicates the infrared signature of an emergency beacon.
beacon_row = -1
beacon_col = -1
for y = 0 to 3
for x = 0 to 3
if thermal_grid[y, x] == 100 then
beacon_row = y
beacon_col = x
endif
next x
next y
| Column 0 | Column 1 | Column 2 | Column 3 | |
|---|---|---|---|---|
| Row 0 | 18 | 19 | 17 | 20 |
| Row 1 | 21 | 18 | 100 | 19 |
| Row 2 | 17 | 22 | 20 | 18 |
| Row 3 | 19 | 16 | 18 | 17 |
State the purpose of the program code in Figure 1.
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.