Learn in your language
Skip to content
A Level · Cambridge (CIE) · 9618

11 Programming and structured design

Write and trace robust pseudocode using data, selection, iteration, procedures, functions and structured programming.

Cambridge International AS & A Level Computer Science 9618 · 2027–2029 · Version 2 · 11

Mapped to Cambridge International AS & A Level Computer Science 9618, 2027–2029 Version 2. These original lessons and self-checks are independent study support; they are not Cambridge papers, official marks or grades. The course does not yet provide a timed four-paper simulation or a locked-down Paper 4 programming environment.

Before you begin

  • Use the 2027–2029 syllabus for your exam year. AS candidates study Sections 1–12; A Level candidates study Sections 1–20. Paper 4 uses a programming language chosen from Python, Java or Visual Basic in console mode.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

Which construct is best when the number of repetitions is known in advance?

What you will learn

  • Explain the key representations, structures or processes in this syllabus section
  • Apply the method to a new computer-science example
  • Justify a design choice and check its limits

Pseudocode describes actions precisely

Declare constants and variables before use; initialise values before reading them. Assignment stores a calculated value, while input obtains data and output communicates a result. Use the pseudocode guide's notation and supplied string routines where needed.

Selection uses IF/ELSE or CASE. Count-controlled loops repeat a known number of times; condition-controlled loops continue while or until a condition changes. Check the loop condition and update to avoid off-by-one errors or infinite loops.

Procedures and functions make programs easier to reason about

A procedure performs an action; a function returns a value. Parameters are names in a subprogram definition; arguments are values passed at a call. A clear interface states parameter types or purpose and the return value.

Structured programming uses sequence, selection and iteration with subprograms to organise the solution. Avoid duplicated logic when a well-named routine can perform one coherent task. Validate input and handle boundary cases explicitly.

Pause and explain

What must a function provide to its caller?

Put the idea to work

Worked example

Write pseudocode to count how many of five entered values are positive.

Show the worked solution
  1. Initialise count to zero before the loop.
  2. Repeat exactly five times, input a value and increment only when it is greater than zero.
  3. Output count after the loop ends.

Answer Count ← 0; FOR i ← 1 TO 5; INPUT value; IF value > 0 THEN Count ← Count + 1; ENDIF; NEXT i; OUTPUT Count.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

A procedure receives a number and returns its square. Identify its parameter and a suitable return value for argument 6.

Give me a hint

Track the named input separately from the value passed in a call.

Compare my reasoning
  1. A parameter might be named number.
  2. At the call, 6 is the argument.
  3. The function returns number × number, which is 36.

Parameter: number; argument: 6; return value: 36.

Look for these in your work

  • Parameter named
  • Argument identified
  • Return calculated
2 · Independent

Write pseudocode logic that repeatedly asks for a mark until it is in the inclusive range 0 to 100.

Give me a hint

Use a condition that rejects values below or above the permitted interval.

Compare my reasoning
  1. Input mark before testing it.
  2. Repeat input while mark < 0 OR mark > 100.
  3. Continue only when the value is within the range.

INPUT mark; WHILE mark < 0 OR mark > 100; INPUT mark; ENDWHILE.

Look for these in your work

  • Bounds inclusive
  • Correct OR condition
  • Input repeats
3 · Transfer

A program calculates totals for three departments using duplicated code. Propose one subprogram interface and explain one benefit.

Give me a hint

Pass the department's values to a routine that returns a total.

Compare my reasoning
  1. Define a function such as DepartmentTotal(values).
  2. The function sums its inputs and returns one result.
  3. Calling the same function for each department reduces duplicated logic and makes testing consistent.

Use a function with department values as an argument and a numeric total as its return value.

Look for these in your work

  • Interface specified
  • Return purpose clear
  • Benefit explained

Common mistakes

  • Initialising a counter inside the loop when it should accumulate across iterations.
  • Using a function when the design needs an action but no returned value, or vice versa.
  • Writing a condition-controlled loop without a path that changes the condition.
Recall without your notes

What can you explain now?

What is the difference between a parameter and an argument?

Compare with the explanation

A parameter is in a subprogram definition; an argument is supplied at a call.

The parameter receives the argument value when the subprogram is called.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

How do selection, iteration, procedures, functions and validation work together in a structured program?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science

Course scope and assessment

This pathway maps the 2026 Version 2 and 2027–2029 Version 2 syllabuses, which Cambridge says have no significant changes affecting teaching. It has original teaching and guided, independent and transfer practice for all 20 syllabus sections, with topic links to the official section headings. It is mapped teaching, not proof of exam readiness or an official Cambridge grade. Paper 4 requires complete programs and testing evidence in a programming environment; the current course offers explained code and algorithm practice but does not yet provide a locked-down timed programming-paper environment, full four-paper mocks or human subject-teacher review.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.