Every 15-mark Paper 2 Q11 solution is 3-5 patterns wired together. Six patterns cover the lot. Master them here and the exam becomes assembly, not invention.
Every Paper 2 Q11 solution is 3-5 patterns wired together. Recognise the patterns, memorise the shapes, and the 15-mark question becomes assembly, not invention. Six patterns cover every scenario Cambridge has set since 2023.
The six patterns Lab B teaches: 1. Validated input loop · 2. SUM aggregation · 3. COUNT with condition · 4. MIN/MAX + find all matches · 5. Nested loop for 2D array · 6. Comments + messages.
"Assemble reusable technique blocks." Lab A read the blueprint. Lab B forges the blocks. Lab C ships the finished 15-mark program.
WHILE vs REPEAT vs FOR for a given taskWrong (Cambridge examiner-cited failure mode from 2025 s25 P22 Q11 — verbatim: "Some candidates used an IF statement to validate the entry, but this only allows for one extra data entry"):
INPUT Score
IF Score < 0 OR Score > 100 THEN
INPUT Score
ENDIF
Right — retries until valid, full marks:
INPUT Score
WHILE Score < 0 OR Score > 100 DO
OUTPUT "Score must be 0 to 100. Try again: "
INPUT Score
ENDWHILE
Alternative valid (REPEAT-UNTIL):
REPEAT
INPUT Score
UNTIL Score >= 0 AND Score <= 100
Total <- 0
FOR i <- 1 TO ArraySize
Total <- Total + Numbers[i]
NEXT i
OUTPUT "The total is ", Total
Count <- 0
FOR i <- 1 TO ArraySize
IF Numbers[i] > Threshold THEN
Count <- Count + 1
ENDIF
NEXT i
OUTPUT "Count above threshold: ", Count
Max <- Values[1]
FOR i <- 2 TO ArraySize
IF Values[i] > Max THEN
Max <- Values[i]
ENDIF
NEXT i
// second pass to output ALL indices with the max value
FOR i <- 1 TO ArraySize
IF Values[i] = Max THEN
OUTPUT Names[i]
ENDIF
NEXT i
Why two passes: 2025 s25 examiner report flags outputting ONE match when multiple exist. Second pass fixes it.
FOR Row <- 1 TO NumRows
RowTotal <- 0
FOR Col <- 1 TO NumCols
RowTotal <- RowTotal + Grid[Row, Col]
NEXT Col
OUTPUT "Row ", Row, " total: ", RowTotal
NEXT Row
Every INPUT gets a prompt message. Every OUTPUT gets a label string. Every logical block gets a // comment explaining its purpose (not what — the code shows what). Cambridge mark scheme axes 4-5 literally reward these.
Valid <- FALSE, exit when set TRUE. Verbose but Cambridge accepts.Bare IF allows exactly ONE retry. If the second input is also invalid, it's stored anyway. Marks lost.
Forgetting Total <- 0 before the SUM loop means the first iteration adds to undefined. Cambridge flags this.
"Output the student with the lowest total" — you output one name and stop. But multiple students can tie. Second pass fixes it.
If all your values are positive, MIN never updates below 0. If all negative, MAX never updates above 0. Both fail silently.
Min <- Values[1]), then loop 2 to ArraySize.Cambridge doesn't want comments like // increment counter — the code already shows that. It wants // count students with screen time over 300 minutes.
IF Score < 0 OR Score > 100 THEN INPUT Score ENDIF valid validation?Total <- 0 on the line before the loop. Miss this and you lose the "not initialising counters" axis.Min <- Values[1], then loop from index 2. Initialising to 0 fails when all values are positive.// increment counter is bad; // count matches above the threshold is good.FOR i <- 0 TO N is off by one at both ends and loses marks.Six patterns · 4 slots each · parser marks your fill against the reference AST.
Getting Started. Why do experienced programmers write faster? Not because they type faster — because they recognise patterns. The same 5 patterns appear on every Paper 2 Q11.
Context. Textbook §11.3 walks through a calculator example: input two values, input an operator, perform the calculation, output the result. Underneath: two INPUT + validate patterns, one selection pattern, one OUTPUT with message. Nothing new — just four patterns wired together.
Discussion. Why is IF Score < 0 THEN INPUT Score broken? What happens if the second input is also invalid?
INPUT Score
IF Score < 0 OR Score > 100 THEN
INPUT Score
ENDIF
Impact: one retry only. If second is bad, it's stored. Cited: 2025 s25 P22 Q11 examiner report.
INPUT Score
WHILE Score < 0 OR Score > 100 DO
OUTPUT "Try again: "
INPUT Score
ENDWHILE
Impact: retries until valid. Full marks on the validation axis.
When: condition may not hold at all — body may not execute.
Cambridge preference: validation loops, sentinel-terminated inputs.
When: body must execute at least once.
Cambridge preference: menu-driven programs, "keep asking until…" flows.
When: known iteration count (array length, week count).
Cambridge preference: array traversal, aggregation.
Warm-up before Pattern Builder. Tap the pattern you'd use, get instant feedback.
| Structure | Pseudocode | When to use |
|---|---|---|
| Pre-check loop | WHILE cond DO … ENDWHILE | Condition may not hold — body may not run |
| Post-check loop | REPEAT … UNTIL cond | Body always runs at least once |
| Count-controlled | FOR i <- 1 TO N … NEXT i | Known iteration count |
| Count + step | FOR i <- 1 TO N STEP 2 … NEXT i | Non-1 increment |
| Selection | IF cond THEN … ELSE … ENDIF | Two-way branch |
| Nested selection | IF … ELSE IF … ELSE … ENDIF | Multi-way branch |
Recurring across all sittings. The 2025 s25 P22 Q11 examiner report says it verbatim.
Forgetting Count <- 0 before the loop. Counter accumulates from undefined.
Fails silently for arrays where all values sit above or below zero. Initialise to the first element instead.
FOR i <- 0 TO N in Cambridge Pseudocode is off by one at both ends. Arrays start at 1.
Iterating columns outer and rows inner is legal but non-standard. Cambridge convention is rows outer.
// increment counter is worthless — the code shows that. // count students over 300 minutes explains purpose.
IF Score < 0 THEN INPUT Score ENDIF, is this correct validation?Six patterns. Cambridge preference for each. Traps to avoid.
Head to Activities — Pattern Builder + 4 partner drills.
Five drills. The signature is Pattern Builder — 6 pattern skeletons with editable slots. The pseudocode parser marks your fill against the reference AST. Behind it: 4 partner drills that isolate sub-skills — loop-choice reflex, initialisation habit, all-matches reflex, and 60-second sprint.
Progressive disclosure: Modes 1-3 open. Modes 4-5 unlock after 2 of 1-3 completed. Mode 6 unlocks after 3 of 1-5.
Given a task, pick the correct loop: WHILE / REPEAT / FOR. Instant feedback with Cambridge reasoning.
Read a code snippet. Tap YES if the initialisation is correct, NO if it will break. Wrong ones flag the trap.
Given a Cambridge output requirement, tap one-pass or two-pass. Second-pass is required whenever the answer could tie.
Rapid recall on all six patterns. Pattern-picking + loop-choice + init-check questions.
6 patterns · progressive unlock
1 · Pattern Builder — signature. Fill slot expressions, parser AST-marks your fill.
2 · Loop-Choice — isolate the WHILE/REPEAT/FOR reflex.
3 · Init Detective — spot bad initialisation before it costs marks.
4 · All-Matches — reflex the second-pass on ties.
5 · Sprint — 60s rapid recall.
Distributed across the 6 patterns and pattern-picking. Adaptive: weak skills surface 2× more often.
Real Cambridge Paper 2 Q11 scenarios from 2023-2025, plus textbook cases. Every citation verified. Answer, then reveal the mark scheme.
The traps here are the ones examiner reports flag repeatedly across 2023-2025. Read this tab the morning of the exam.
Six one-liners. Recite these before your exam.
Tick each item as you internalise it. Tap a skill status to override the automatic marker. When all 12 are ticked, the Module Mastered banner appears.
Once all 12 checked → Lab C · Ship (Deliverable). Full 15-mark end-to-end programs.
Every wrong answer captures here automatically.
Your attempts, accuracy, and mastery counts across Lab B.
Spotted something wrong or unclear? Log it here.