Programming and Software Development
Programming and Software Development tests whether you can write and interpret small programs, use control structures and subprograms correctly, and explain how software is planned, tested, and maintained.
Core rules and concepts
- Variables store values of a data type: integer, real, Boolean, character, or string. Identifiers should be meaningful and not reserved words.
- Assignment changes a variable; comparison checks a condition. In many languages = assigns and == compares.
- Sequence, selection (IF/CASE), and iteration (FOR, WHILE, REPEAT) are the three control structures.
- A function returns a value; a procedure performs an action. Parameters pass data in; local variables exist only inside the subprogram, while global variables are visible more widely.
- The software development life cycle includes requirements, design, implementation, testing, deployment, and maintenance. Testing finds defects; debugging locates and fixes them.
Worked example
Trace: total ← 0 FOR i ← 1 TO 4 total ← total + i * i NEXT i OUTPUT total
i = 1: total = 0 + 1 = 1 i = 2: total = 1 + 4 = 5 i = 3: total = 5 + 9 = 14 i = 4: total = 14 + 16 = 30 Output: 30. Reasoning: the loop runs four times; each iteration adds the square of i to the running total. The accumulator is initialised before the loop, which is essential.
Traps
- Using = where == is needed in a condition.
- Off-by-one errors in FOR loops and WHILE conditions.
- Forgetting to initialise an accumulator or counter.
- Assuming integer division gives a decimal; 7 / 2 may be 3 in integer arithmetic.
- Changing a local variable and expecting it to exist outside the subprogram.