Programming and Problem Solving
What you must know
Programming solves problems through algorithms: sequence, selection and iteration. Learn variables and constants, data types (integer, real, string, Boolean), operators, input/output, subprograms (procedures and functions), parameters, and flowcharts/pseudocode. Understand testing with normal, boundary and erroneous data, and the difference between syntax and logic errors. Know how to trace a program and dry-run it with sample values.
Traps candidates fall into
- Mixing = (assignment) with == (comparison).
- Forgetting that a loop needs a condition that eventually becomes false.
- Using the wrong data type - a string cannot do arithmetic.
- Skipping boundary tests (e.g. exactly 0 or 100).
- Confusing a function (returns a value) with a procedure (does not).
Rule of thumb
Write pseudocode in three parts: input, process, output. Then test with normal, boundary and erroneous data.
Worked example
Average of three numbers:
INPUT a, b, c
avg = (a + b + c) / 3
OUTPUT avg
Test with 3, 6, 9 → 6 (normal); 0, 0, 0 → 0 (boundary); "cat" → erroneous, needs validation.