AS & A Level Computer Science (9618)

AS Level · Topics 9–12

Design, trace, and test an AS program

Combine decomposition, records, arrays, subroutines, files, and a test plan.

Lessons distinguish AS topics 1–12 from A Level topics 13–20. Examples include Cambridge pseudocode and Python.

Write a contract for each subroutine

Specify the input, output, and assumptions before choosing an algorithm. A record can group attributes of one item; an array holds multiple values addressed by an index. Choose bounds explicitly and distinguish a stored count from the array's capacity.

Use local variables to keep a subroutine's temporary work separate. A parameter passed by value supplies a value; a by-reference parameter can let the subroutine change the caller's storage. State the intended effect before deciding which is appropriate.

Pseudocode
DECLARE Marks : ARRAY[1:3] OF INTEGER
DECLARE Index : INTEGER
DECLARE Total : INTEGER
Marks[1] <- 40
Marks[2] <- 50
Marks[3] <- 80
Total <- 0
FOR Index <- 1 TO 3
    Total <- Total + Marks[Index]
NEXT Index
OUTPUT Total

Test the design as well as the code

For the example, a trace should finish with Total = 170. Test first and last indices to expose boundary mistakes. For input routines, include normal, extreme, and invalid data and state the expected result of each test.

The development cycle connects analysis, design, implementation, testing, and maintenance. For file processing, define the record format and end-of-file handling. After a maintenance change, rerun relevant tests to check previously working behavior.

Check yourself

Does an array capacity of 100 mean that 100 meaningful items have been stored?Show answer

No. Track the number of populated elements separately from allocated capacity.

References used to build these lessons

We used these official documents as references when building this course's lessons. They are the sources for the syllabus structure and course requirements.

Cambridge International · 9618 · Exams 2027–2029