What are the core programming constructs every imperative program is built from?
Understand and use the three basic programming constructs (sequence, selection and iteration), definite and indefinite iteration, nested constructs, and the meaning of constants and variables.
A focused answer to AQA A-Level Computer Science 4.1.2, covering the three basic constructs sequence, selection and iteration, definite and indefinite iteration, nesting, and the difference between constants and variables.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
AQA wants you to describe and use the three basic programming constructs (sequence, selection and iteration), to distinguish definite from indefinite iteration, to nest one construct inside another, and to explain the difference between a constant and a variable.
The three basic constructs
- Sequence: read a number, double it, then print it. Order matters: changing it changes the result.
- Selection:
IF mark >= 50 THEN print "Pass" ELSE print "Fail". A condition decides which branch runs. ACASEstatement is a tidy way to select among many values of one variable. - Iteration: repeating a block, for example printing the numbers 1 to 10.
These three are the building blocks from which every more complex structure is assembled, which is why they are introduced first. The conditions used in selection and iteration are Boolean expressions built from the relational and logical operators, linking this topic directly to arithmetic and logical operations.
Definite and indefinite iteration
FOR i = 1 TO 10 # definite: runs exactly 10 times
OUTPUT i
ENDFOR
WHILE guess != answer # indefinite: runs until the user is correct
guess = USERINPUT
ENDWHILE
A WHILE loop is condition-controlled and tests before the body, so it may run zero times if the condition is false at the start. A REPEAT UNTIL loop tests after the body, so it always runs at least once. Choosing the right one matters: validating input that might already be acceptable suits a WHILE, while a menu that should always display once suits a REPEAT UNTIL. Every iteration must make progress towards ending, or the loop never terminates.
Nesting and variables versus constants
Constructs can be nested: a selection inside a loop, or a loop inside a loop. A nested loop is the standard way to process a two-dimensional array, with the outer loop stepping through the rows and the inner loop through the columns of each row, so the inner body runs once per cell.
A variable is a named store whose value can change during execution. A constant is a named value fixed once and never changed, for example VAT = 0.20. Constants make code clearer and safer because the value cannot be accidentally altered, and changing it in one place updates the whole program. Using a named constant rather than a bare literal also documents intent: VAT is more readable than the number 0.20 scattered through the code.
Exam-style practice questions
Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
AQA 20194 marksExplain the difference between definite and indefinite iteration, and for each give one situation where it is the appropriate choice. Name the loop construct used in each case.Show worked answer →
Definite iteration repeats a block a fixed, known number of times, controlled by a counter, using a FOR loop. It is appropriate when the number of repetitions is known in advance, for example printing each of the 12 months or processing every element of an array of known length.
Indefinite iteration repeats while or until a condition holds, where the number of repetitions is not known in advance, using a WHILE or REPEAT UNTIL loop. It is appropriate when repetition depends on input or a result, for example asking the user to re-enter a password until it is correct, where the number of attempts cannot be predicted.
Markers reward the known-count versus condition-controlled distinction, naming FOR for definite and WHILE or REPEAT UNTIL for indefinite, and a valid scenario for each.
AQA 20213 marksDescribe what is meant by nesting of programming constructs and explain why a constant is preferable to a variable for a fixed value such as a VAT rate.Show worked answer →
Nesting means placing one construct inside another, for example a selection inside a loop, or a loop inside another loop. A nested loop is commonly used to process a two-dimensional array, with the outer loop over the rows and the inner loop over the columns.
A constant is preferable for a fixed value such as a VAT rate because its value is set once and cannot be changed during execution, so it cannot be altered accidentally by other parts of the program. It also improves maintainability: if the rate changes, it is updated in a single declaration and the change propagates everywhere it is used, and a meaningful name makes the code more readable than a bare number.
Markers reward defining nesting with an example and at least two reasons for the constant (cannot be changed accidentally, single point of update, readability).
Related dot points
- Understand the built-in data types: integer, real or float, Boolean, character and string, and understand records, arrays and user-defined data types built from them.
A focused answer to AQA A-Level Computer Science 4.1.1, covering the built-in data types (integer, real, Boolean, character, string), how each is stored, and how records, arrays and user-defined types are built from them.
- Use arithmetic operations including integer division, modulus and exponentiation, relational operators, and the Boolean operators AND, OR and NOT, and understand operator precedence.
A focused answer to AQA A-Level Computer Science 4.1.3, covering arithmetic operators including integer division and modulus, relational operators, the Boolean operators AND, OR and NOT, and operator precedence.
- Understand and use subroutines (procedures and functions), parameters, return values, local and global variables, scope, and the use of an interface and recursion.
A focused answer to AQA A-Level Computer Science 4.1.4 and 4.1.6, covering procedures and functions, parameters and return values, local and global scope, the benefits of subroutines, and recursion.
- Understand classes and objects, attributes and methods, instantiation, encapsulation, inheritance and polymorphism, and the principle of object-oriented design.
A focused answer to AQA A-Level Computer Science 4.1.5, covering classes and objects, attributes and methods, instantiation, encapsulation, inheritance and polymorphism, and the benefits of object-oriented design.
- Understand the linear search and binary search algorithms, how each works, their requirements, and their time complexity.
A focused answer to AQA A-Level Computer Science 4.3.2, covering the linear search and binary search algorithms, how each works, the requirement that binary search needs sorted data, and their time complexity.
Sources & how we know this
- AQA A-level Computer Science (7517) specification — AQA (2015)