Computer Science
04782026–2028 syllabus

COMPUTER SCIENCE · CHAPTER 7

Programming

Build maintainable programs using data, control structures, arrays, files and modular design.

Full syllabus5 connected sectionsSyllabus-aligned guide

LEARNING OBJECTIVES

What you will be able to do

  • select data types, variables, constants and operators
  • use sequence, selection and iteration
  • manipulate strings, arrays and files
  • design procedures and functions with appropriate scope

AT A GLANCE

Syllabus0478Coverage2026–2028Sections5LevelFull syllabus

INTRODUCTION · THE BIG IDEA

Build maintainable programs using data, control structures, arrays, files and modular design.

Programming translates an algorithm into precise statements a computer can execute. Correctness comes first, followed by readability, maintainability and robustness.

The syllabus expects practical experience writing, executing, testing and debugging programs as well as reading pseudocode.

01

SECTION 01

Data types, variables and operators

Core concept

Common data types are integer, real, character, string and Boolean. A constant has a named value that does not change. Type choice affects valid operations, storage and input checking.

Arithmetic operators include +, −, *, /, integer division DIV and remainder MOD. Relational operators compare values and Boolean operators AND, OR and NOT combine conditions. Precedence matters, so parentheses improve clarity.

Original worked example

Using DIV and MOD

  1. Convert 367 seconds to minutes and seconds.
  2. Minutes = 367 DIV 60 = 6.
  3. Seconds = 367 MOD 60 = 7.

Answer: 367 seconds is 6 minutes 7 seconds.

02

SECTION 02

Selection and iteration

Core concept

IF statements make one- or two-way decisions; nested IF handles dependent conditions; CASE selects among discrete values. Conditions should be mutually clear and cover required alternatives.

A count-controlled FOR loop repeats a known number of times. A pre-condition WHILE loop may run zero times; a post-condition REPEAT loop runs at least once. Choose the structure that matches the termination rule.

Loop choice
StructureUse whenKey feature
FORrepeat count knowncontrol variable changes automatically
WHILEtest before each passmay execute zero times
REPEATtest after each passexecutes at least once
03

SECTION 03

Strings and arrays

Core concept

String operations can find length, extract a substring, convert case and access characters. Index rules must match the pseudocode convention used in the question.

A one-dimensional array stores a list under one identifier; a two-dimensional array stores rows and columns. Arrays use loops for input, search, total and update. Parallel arrays use the same index for related values, though records are often clearer in real programs.

Original worked example

Average of an array

  1. Initialise Total to 0 before the loop.
  2. For each of 5 scores, add Scores[Index] to Total.
  3. After the loop, calculate Total / 5.

Answer: The accumulator must be initialised once, not reset during each iteration.

04

SECTION 04

Procedures, functions and scope

Core concept

A procedure performs a task; a function returns a value. Parameters pass information and can be by value or by reference where specified. Local variables exist within one module; global variables are widely accessible but increase coupling.

Modules reduce duplication, support team development and can be tested independently. Interfaces should clearly state parameter types and returned results. Maintainable code uses meaningful identifiers, indentation and comments that explain purpose rather than repeat statements.

ORIGINAL STUDY DIAGRAMDesign a module
1Give one clear responsibility
2Define typed parameters
3Use local working data
4Return or update only required result
5Test independently
05

SECTION 05

Files, robustness and maintenance

Core concept

Text files provide persistent sequential storage. A program opens a file in read or write mode, processes records and closes it. End-of-file checks prevent reading beyond available data; write mode may overwrite existing content.

Robust programs validate input, handle exceptional cases and give clear messages. Syntax errors break language rules, runtime errors occur during execution and logic errors produce incorrect results. Test, locate, correct and retest each fault.

Corrective maintenance fixes faults, adaptive maintenance responds to environment change and perfective maintenance improves performance or usability.

ORIGINAL STUDY DIAGRAMSafe file processing
1Open in correct mode
2Check end-of-file
3Read and validate record
4Process or write
5Close file

QUICK CHAPTER SUMMARY

The ideas to carry forward

  • Choose types and operators deliberately.
  • Control structures should mirror the algorithm's decision and repetition rules.
  • Arrays and files organise repeated and persistent data.
  • Modular programs are easier to test and maintain.

QUICK REVISION CHECKLIST

Can you do each of these without your notes?

  • select data types, variables, constants and operators
  • use sequence, selection and iteration
  • manipulate strings, arrays and files
  • design procedures and functions with appropriate scope