Programming — AQA GCSE Computer Science
This is the largest topic. It covers the programming constructs and techniques used to write and test programs.
Data types and variables
Common data types: integer, real (float), Boolean, character and string. A variable stores a value that can change; a constant stores a value that does not change. Casting converts between data types.
The three programming constructs
- Sequence — statements run in order.
- Selection —
IF … ELSEandCASE/SWITCHstatements make decisions. - Iteration — loops repeat code:
- count-controlled (
FOR) — runs a set number of times, - condition-controlled (
WHILE/REPEAT UNTIL) — runs until a condition is met.
- count-controlled (
Operators
- Arithmetic: + − × / , plus integer division (DIV) and modulus (MOD) (remainder).
- Comparison: =, ≠, <, >, ≤, ≥.
- Boolean: AND, OR, NOT.
Data structures
- Arrays (and lists) store multiple values under one name, accessed by an index. They can be one- or two-dimensional.
- Records store related fields of different types.
- Strings can be manipulated: length, substring, position, concatenation, and converting case.
Subroutines
Procedures and functions are named blocks of code (subroutines). A function returns a value; a procedure does not. They allow parameters to be passed in, support decomposition and reuse, and have local and global variables.
Other techniques
- File handling — reading from and writing to text files.
- Random number generation.
- SQL to query a database (covered separately).
- Validation (checking input is sensible) and authentication.
Testing
Programs are tested with normal, boundary and erroneous data to find and fix errors (syntax errors and logic errors).
Exam tips
- Learn the three constructs: sequence, selection, iteration.
- Know DIV and MOD and the Boolean operators.
- A function returns a value; a procedure does not.
- Test with normal, boundary and erroneous data; distinguish syntax vs logic errors.