Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.
Read the declaration and the loop:
| Answer | |
|---|---|
| The dimension of the array | 2 |
| The name of the variable used as an array index | PCount |
| The number of elements in the array | 100 |
Dimension is 2 because there are two index ranges [1]
Index variable is PCount [1]
2 × 50 = 100 elements [1]
Error: the second dimension of the array is declared from 1 to 50, but the loop runs from 0 to 49 [1]
Line number: 10 (also accepted: 100, 101 or 102) [1]
Write: INTEGER [1]
Decide what each statement does:
| Pseudocode statement | Input | Process | Output |
|---|---|---|---|
| INPUT MyChoice | ✓ | ||
| OUTPUT FirstName & LastName | ✓ | ✓ | |
| WRITEFILE YourFile, TextLine | ✓ | ||
| READFILE MyFile, TextLine | ✓ | ||
| Result ← SQRT(NextNum) | ✓ |
OUTPUT FirstName & LastName: Process and Output ticked (joining the strings is a process) [1]
WRITEFILE: Output ticked [1]
READFILE: Input ticked [1]
Result ← SQRT(NextNum): Process ticked [1]
▶ Starts at Q1 (1:30)
Starts at Q1 (1:30) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.