Programming Fundamentals and Logic
What the domain covers
Programming Fundamentals and Logic tests algorithm writing, flowcharts, pseudocode, variables, control structures and debugging. The exam rewards dry-running code accurately, not memorising syntax.
Core rules
- An algorithm is a finite ordered set of steps; a flowchart shows it with standard symbols: oval for start/end, parallelogram for input/output, rectangle for process, diamond for decision, arrows for flow.
- A variable is a named storage location whose value can change; a constant does not. Data types include integer, real/float, character, string and Boolean.
- Control structures: sequence (one step after another), selection (
if/else), iteration (for,while). A loop needs initialisation, a condition and an update to avoid infinite repetition. - Common operators:
+ - * /,modfor remainder, comparison=,<>,<,>, and BooleanAND,OR,NOT. In pseudocode,←or=may mean assignment; read the question’s convention. - Errors: syntax (grammar), logic (wrong result), runtime (fails while running).
Worked example
Pseudocode: sum ← 0; for i ← 1 to 5; sum ← sum + i; end for; print sum. Dry run: sum becomes 1, 3, 6, 10, 15. Output 15. If the loop ran to 6, the output would be 21, an off-by-one error.
Traps
- Confusing
=assignment with==comparison. - Forgetting to update the loop variable, causing an infinite loop.
- Ignoring integer division:
7 / 2may give 3 in integer arithmetic. - Declaring a variable but using it before assigning a value.