Statement types in programs

The Building Blocks of a Program

Every program you write is made up of a small set of fundamental statement types. Understanding what each type does, and how to combine them, is the foundation of all programming. AQA requires you to recognise and use six statement types: variable declaration, constant declaration, assignment, iteration, selection, and subroutine.

These building blocks exist in every high-level programming language - whether you are writing Python, VB.NET, or C#. The syntax differs, but the underlying concept is identical.

Statement Type What it does Quick example (pseudocode)
Variable declaration Creates a named memory location that can hold a value which may change during the program score ← 0
Constant declaration Creates a named value that is set once and cannot be changed during the program CONST MAX_SCORE = 100
Assignment Stores a value into a variable (can be used to set or update the value) score ← score + 10
Selection Chooses between different paths through the program based on a condition IF score > 50 THEN ...
Iteration Repeats a block of statements either a fixed number of times or while a condition holds WHILE lives > 0 DO ...
Subroutine A named, reusable block of code. A procedure performs an action; a function performs an action and returns a value SUBROUTINE greet(name)

Variables and Constants - Why Use Named Identifiers?

You could write a program using literal values directly - for example, writing 70 every time you mean the speed limit. But using a named constant such as SPEED_LIMIT = 70 is far better practice, for two important reasons.

First, readability: the name tells you instantly what the value means. A reader seeing SPEED_LIMIT understands the purpose immediately, whereas a bare 70 requires context to interpret. Second, maintainability: if the value ever needs to change, you update it in one place - the constant declaration - rather than finding and changing every occurrence scattered through the code. One change fixes the whole program.

Named variables serve the same readability purpose, and they add the ability to store values that are not known until the program runs - such as user input, calculated results, or a score that changes as a game progresses. A variable holds the current state of a piece of data; a constant holds a value that is fixed by design.

The Three Combining Principles

AQA identifies three fundamental principles that describe how statements are combined in every high-level imperative language. These are not separate statement types - they are the structural patterns that connect statements together.

  • Sequence: statements execute one after another in the order they are written. This is the default - unless selection or iteration changes the flow.
  • Selection: a condition is evaluated. Depending on the result, different sequences of statements are executed. This allows programs to make decisions.
  • Iteration: a sequence of statements is repeated, either a fixed number of times (count-controlled) or as long as a condition remains true (condition-controlled).

Any program - no matter how complex - is ultimately built from these three patterns. Selection and iteration are both statement types you need to use, but they are also the structural tools that shape the entire flow of a program.

Worked Examples

The three examples below are scaffolded - each builds on the last, introducing more statement types as complexity increases. Annotations in each example show which statement type each line represents.

This example introduces variable declaration, assignment, and a subroutine (procedure). A procedure performs an action but does not return a value.

# Python — Example 1: variable, assignment, subroutine (procedure)

def greet(name):                              # subroutine declaration (procedure)
    message = "Hello, " + name + "!"         # variable declaration + assignment
    print(message)                           # executes in sequence

user_name = "Alice"                          # variable declaration + assignment
greet(user_name)                             # subroutine call (sequence)
' VB.NET — Example 1: variable, assignment, subroutine (procedure)

Sub Greet(name As String)                     ' subroutine declaration (procedure)
    Dim message As String = "Hello, " & name & "!"  ' variable declaration + assignment
    Console.WriteLine(message)                ' executes in sequence
End Sub

Dim userName As String = "Alice"              ' variable declaration + assignment
Greet(userName)                               ' subroutine call (sequence)
// C# — Example 1: variable, assignment, subroutine (procedure)

void Greet(string name)                       // subroutine declaration (procedure)
{
    string message = "Hello, " + name + "!"; // variable declaration + assignment
    Console.WriteLine(message);              // executes in sequence
}

string userName = "Alice";                   // variable declaration + assignment
Greet(userName);                             // subroutine call (sequence)

This example adds constant declaration and selection. Notice how the constant MAX_SCORE is used in the condition rather than a bare number - this is clearer and easier to maintain.

# Python — Example 2: constant, variable, assignment, selection

MAX_SCORE = 100                              # constant declaration (UPPER_CASE convention)
score = 0                                    # variable declaration + assignment

score = score + 75                           # assignment — updating the variable

if score >= MAX_SCORE:                       # selection — condition-controlled branch
    print("Full marks!")
elif score >= 50:                            # selection — alternative branch
    print("Pass. Score:", score)
else:                                        # selection — default branch
    print("Fail. Score:", score)
' VB.NET — Example 2: constant, variable, assignment, selection

Const MAX_SCORE As Integer = 100             ' constant declaration
Dim score As Integer = 0                     ' variable declaration + assignment

score = score + 75                           ' assignment — updating the variable

If score >= MAX_SCORE Then                   ' selection — condition-controlled branch
    Console.WriteLine("Full marks!")
ElseIf score >= 50 Then                      ' selection — alternative branch
    Console.WriteLine("Pass. Score: " & score)
Else                                         ' selection — default branch
    Console.WriteLine("Fail. Score: " & score)
End If
// C# — Example 2: constant, variable, assignment, selection

const int MAX_SCORE = 100;                   // constant declaration
int score = 0;                               // variable declaration + assignment

score = score + 75;                          // assignment — updating the variable

if (score >= MAX_SCORE)                      // selection — condition-controlled branch
{
    Console.WriteLine("Full marks!");
}
else if (score >= 50)                        // selection — alternative branch
{
    Console.WriteLine("Pass. Score: " + score);
}
else                                         // selection — default branch
{
    Console.WriteLine("Fail. Score: " + score);
}

This example combines all six statement types. Read the annotations carefully - notice how iteration wraps around a selection, and how the subroutine (function) is called from inside the loop. A function differs from a procedure in that it returns a value to the calling code.

# Python — Example 3: all six statement types

MAX_ATTEMPTS = 3                             # constant declaration

def check_password(attempt):                 # subroutine declaration (function — returns a value)
    correct = "secret123"                    # variable declaration + assignment
    return attempt == correct                # returns True or False

attempts = 0                                 # variable declaration + assignment
logged_in = False                            # variable declaration + assignment

while attempts < MAX_ATTEMPTS and not logged_in:   # iteration (condition-controlled loop)
    password = input("Enter password: ")           # variable declaration + assignment
    if check_password(password):                   # selection + subroutine call
        logged_in = True                           # assignment — updating variable
        print("Access granted.")
    else:
        attempts = attempts + 1                    # assignment — updating variable
        print("Incorrect. Attempts used:", attempts)

if not logged_in:                            # selection (outside loop)
    print("Account locked after", MAX_ATTEMPTS, "attempts.")
' VB.NET — Example 3: all six statement types

Const MAX_ATTEMPTS As Integer = 3            ' constant declaration

Function CheckPassword(attempt As String) As Boolean  ' subroutine (function — returns value)
    Dim correct As String = "secret123"      ' variable declaration + assignment
    Return attempt = correct                 ' returns True or False
End Function

Dim attempts As Integer = 0                  ' variable declaration + assignment
Dim loggedIn As Boolean = False              ' variable declaration + assignment

Do While attempts < MAX_ATTEMPTS And Not loggedIn    ' iteration (condition-controlled loop)
    Console.Write("Enter password: ")
    Dim password As String = Console.ReadLine()      ' variable declaration + assignment
    If CheckPassword(password) Then                  ' selection + subroutine call
        loggedIn = True                              ' assignment — updating variable
        Console.WriteLine("Access granted.")
    Else
        attempts = attempts + 1                      ' assignment — updating variable
        Console.WriteLine("Incorrect. Attempts used: " & attempts)
    End If
Loop

If Not loggedIn Then                         ' selection (outside loop)
    Console.WriteLine("Account locked after " & MAX_ATTEMPTS & " attempts.")
End If
// C# — Example 3: all six statement types

const int MAX_ATTEMPTS = 3;                  // constant declaration

bool CheckPassword(string attempt)           // subroutine declaration (function — returns value)
{
    string correct = "secret123";            // variable declaration + assignment
    return attempt == correct;               // returns true or false
}

int attempts = 0;                            // variable declaration + assignment
bool loggedIn = false;                       // variable declaration + assignment

while (attempts < MAX_ATTEMPTS && !loggedIn) // iteration (condition-controlled loop)
{
    Console.Write("Enter password: ");
    string password = Console.ReadLine();    // variable declaration + assignment
    if (CheckPassword(password))             // selection + subroutine call
    {
        loggedIn = true;                     // assignment — updating variable
        Console.WriteLine("Access granted.");
    }
    else
    {
        attempts = attempts + 1;             // assignment — updating variable
        Console.WriteLine("Incorrect. Attempts used: " + attempts);
    }
}

if (!loggedIn)                               // selection (outside loop)
{
    Console.WriteLine("Account locked after " + MAX_ATTEMPTS + " attempts.");
}

 Key Takeaways

  • Every program is built from six statement types: variable declaration, constant declaration, assignment, selection, iteration, and subroutine.
  • Named constants improve readability and maintainability - one change to the declaration updates the value everywhere it is used.
  • Named variables store values that can change during program execution, such as user input or running totals.
  • The three combining principles are sequence (default order), selection (decisions), and iteration (repetition) - all high-level languages are built from these.
  • A procedure (subroutine) performs an action but returns nothing; a function (subroutine) performs an action and returns a value to the calling code.
  • These statement types appear in every language - only the syntax differs. The concepts you learn here transfer directly to Python, VB.NET, C#, and beyond.