Mock-driven revision system
Turn every lost mark into a repeatable method.
Revise the complete Weeks 1–4 syllabus, repair the exact patterns behind your mocks, and practise 65 archived past-paper questions alongside 69 focused questions.
Today
Four-part sprint
Evidence from your mock
Lost-mark map
- HighNested-loop countingAnswered 32; expected 15
- High
continuetracingSkipped value was still printed - MediumExpression evaluation
&&, integer division,%, compound assignment - MediumMSQ completenessTwo partially correct answers
Official Weeks 1–4 scope
Revision notes
Use the rules, then test yourself with the worked example before opening the answer.
How a computer works
Memory and computation
Think of the CPU as a worker with a few very fast working slots called registers. RAM holds the larger working set, while the Program Counter tells the CPU where the next instruction is. The basic cycle is fetch → decode → execute.
- Program Counter: address of the next instruction
- Hierarchy: Registers → Cache → RAM → SSD
- Load: memory to register
- Store: register to memory
- Split memory: instructions and data use separate paths
- Memory-mapped I/O: devices are accessed through addresses
- Write the old value of every register and memory location.
- Evaluate the right-hand side using only those current values.
- Write the result into the left-hand destination; change nothing else.
Worked load example
R[0] = 4
M[4] = 31
R[1] ← M[R[0]]
M[R[0]] = M[4] = 31
Therefore R[1] = 31Common Week 1 traps
Load versus store: follow the arrow. If the arrow ends at a register, it is a load. If it ends at memory, it is a store. Cache is faster than RAM but smaller; SSD is persistent but much slower than registers and cache.
Data representation
Bits, encoding and compilation
A bit is one binary choice, 0 or 1. With n bits there are 2n distinct patterns. Unsigned numbers use every pattern for zero or a positive value; two’s complement uses half the patterns for negative values.
- Unsigned n-bit: 0 to 2n−1
- Two’s complement: −2n−1 to 2n−1−1
- Negative value: invert positive bits, then add 1
- Hexadecimal: one digit represents four bits
- Characters: ASCII/Unicode map characters to numbers
- Compilation: C source becomes machine instructions
For binary to decimal, label positions from right to left as 1, 2, 4, 8, 16… and add the positions containing 1. For binary to hexadecimal, split from the right into groups of four bits and convert each group separately.
Worked −12 example
+12 00001100
Invert 11110011
Add 1 11110100
−12 = 11110100Range and instruction-size method
For an unsigned n-bit value, write 0 to 2n−1. For signed two’s complement, write −2n−1 to 2n−1−1. For instruction size, calculate the bits needed for each independent choice—opcode, register, and address—then add them.
C fundamentals
Types, operators and expressions
C evaluates an expression according to precedence and associativity, not simply from left to right. Parentheses first, then multiplication/division/remainder, then addition/subtraction, followed by comparisons and logical operators.
- Built-in types:
char,int,float,double - Not built-in C types:
string,class - Integer division:
7 / 3gives2 - Remainder:
7 % 3gives1 - Logical result: false is 0; true is 1
- Assignment: chained assignments evaluate right to left
- Copy the initial value of each variable.
- Resolve parentheses and high-precedence operators.
- For
x++, use the old value and increment afterward; for++x, increment first. - Update variables after each complete statement.
Pre- versus post-increment
int x = 6;
int y = x++ + 4;
y uses 6, so y = 10
then x becomes 7Logical and compound-assignment traps
&& is true only when both sides are non-zero; || is true when either side is non-zero. In a += b += c, work from the right: update b first, then use the new b to update a.
Control flow
Conditions and loops
Every loop has four questions: What is the starting value? What condition allows another iteration? What happens in the body? How does the control variable change? A nested loop repeats the complete inner loop for every legal outer-loop value.
if: zero is false; non-zero is trueswitch: execution falls through withoutbreakcontinue: skip the rest of this iterationbreak: exit the loop immediately- Single loop: list every legal control-variable value
- Nested loop: restart the inner loop for each outer value
Never multiply loop limits until you know the inner count is constant. If the inner condition contains the outer variable, make one row for each outer value and add the row counts.
The five-column tracing method
Iteration | i before | condition | body/output | i after
1 | 2 | 2 <= 8 | print C | 4
2 | 4 | 4 <= 8 | print C | 6
3 | 6 | 6 <= 8 | print C | 8
4 | 8 | 8 <= 8 | print C | 10
stop | 10 | false | — | —Worked dependent nested loop
for (i = 2; i <= 4; i++)
for (j = 1; j <= i; j++)
printf("*");
i = 2 → 2 prints
i = 3 → 3 prints
i = 4 → 4 prints
Total = 2 + 3 + 4 = 9continue skips the remaining body for only the current iteration. break exits the nearest loop completely.
Personalised from your mock
Repair lab
Learn the method behind every lost-mark pattern, then practise a changed version.
Dependent nested loops
for (i = 0; i < 5; i++) {
for (j = 5; j > i; j--) {
printf("Hello C\n");
}
}
The inner limit contains i, so the inner count changes on every outer iteration. Do not multiply two fixed counts.
Assembly loops and missing jump instructions
Assembly uses different words, but it is still a loop. Translate one instruction at a time: MOV sets a value, CMP checks it, JE exits when equal, ADD updates the accumulator, DEC subtracts 1, and JMP repeats.
MOV R1, 10
MOV R2, 0
LOOP:
CMP R1, 0
JE END
ADD R2, R1
DEC R1
JMP LOOP
END:
JE END; no addition55- Circle the steps that must repeat. Loading a new memory value means the jump must return to the load step.
- Write the legal indexes. Ten values at M[0]–M[9] means continue while the index is
< 10. - Reject
<= 10: it would read M[10], which is reserved for the final answer.
The focused set now tests every related Week 1–4 pattern: instruction meanings; final register values; iteration counts; formulas; equivalent C loops; missing jump targets and boundaries; infinite loops; load/store direction; sum and product accumulators; repeated-addition multiplication; register expressions; zeroing a register; instruction-bit calculation; and memory-mapped input/output.
continue skips the body
for (i = 0; i < 5; i++) {
if (i == 2) continue;
printf("%d ", i);
}
At i = 2, printing is skipped. The update still occurs, so the output is 0 1 3 4.
Logical expressions
(x >= y) && (x / y == 2)
Evaluate each comparison as 0 or 1. With &&, the result is 1 only when both sides are true. Read whether the question asks for output 0 or output 1.
Compound assignment
a = b = c = d = 2;
a += b += c += d;
Work right to left: c=4, then b=6, then a=8. Only after that should you evaluate the next expression.
Check every option independently
For multiple-select questions, do not stop after finding one true option. Mark every option T/F, then select the complete true set. Equivalent forms such as [−2³¹, 2³¹−1] and [−2³¹, 2³¹) can both be correct.
Built-in data types
int and char are C types. C has no built-in string type and no class keyword. Strings are arrays of char.
Exact-set scoring
Complete question practice
Choose all 134 questions, the complete 26-question Assembly & Registers set, the 65-question past-paper archive, one paper, one week, or only weak areas.