Skip to main content
Northern IrelandSoftware Systems DevelopmentSyllabus dot point

How do sequence, selection and iteration control the flow of an object oriented program?

The three control structures - sequence, selection (if and case) and iteration (definite and indefinite loops) - and tracing the flow of execution.

A CCEA A-Level Software Systems Development answer on the three control structures: sequence, selection with if and case statements, and iteration with definite and indefinite loops, plus how to trace program flow.

Generated by Claude Opus 4.812 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

CCEA expects you to describe the three fundamental control structures - sequence, selection and iteration - that govern the order in which statements run. You must know if and case for selection, definite (count-controlled) and indefinite (condition-controlled) loops for iteration, including pre-test and post-test loops, and you must be able to trace the flow of a given fragment. These structures appear in every program and are tested both as definitions and through code tracing.

The answer

Sequence

Sequence alone can solve only fixed, linear problems. Order matters: swapping two statements can change the result, for example you must read a value before you use it.

Selection

Selection chooses between alternative paths according to a condition. The if statement is the main form, with optional else and else if branches; the case (or switch) statement is a tidy way to choose among many fixed values of one variable.

if temperature > 30 then
    print("Hot")
else if temperature < 10 then
    print("Cold")
else
    print("Mild")
end if
case grade of
    "A": print("Excellent")
    "B": print("Good")
    else: print("Keep working")
end case

A case is clearer than a long chain of else if when one variable is compared against several constant values.

Iteration

for i = 1 to 10            // definite: runs exactly 10 times
    print(i)
next i

while not validPassword    // indefinite, pre-test
    askForPassword()
end while

repeat                     // indefinite, post-test
    rollDice()
until score >= 100

Worked example: tracing nested control structures

Examples in context

Example 1. A cash machine menu. A case statement selects the action from the option the user presses (1 withdraw, 2 balance, 3 statement), an indefinite while loop keeps the menu showing until the user chooses to exit, and a sequence of statements carries out each chosen action in order. All three structures appear in one screen.

Example 2. Validating an input range. A repeat ... until loop asks for a number and re-asks until it is between 1 and 100. Because it is a post-test loop it always runs at least once, which suits "keep asking until the input is valid", and the selection inside reports the error each time the value is out of range.

Try this

Q1. Name the three basic control structures. [3 marks]

  • Cue. Sequence, selection and iteration.

Q2. State whether a while loop or a repeat until loop is guaranteed to execute its body at least once, and explain why. [2 marks]

  • Cue. repeat until, because it is a post-test loop that checks the condition only after the body has run.

Q3. State how many times for i = 3 to 7 executes its body. [1 mark]

  • Cue. Five times (i takes the values 3, 4, 5, 6, 7).

Exam-style practice questions

Practice questions written in the style of CCEA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

CCEA 20186 marksDescribe the three basic control structures used in programming, giving a short pseudocode example of each.
Show worked answer →

The three control structures are sequence, selection and iteration.

Sequence means statements are carried out one after another in the order written:

total = price + tax
print(total)

Selection chooses between alternative paths based on a condition, using an if (or case) statement:

if mark >= 40 then
    print("Pass")
else
    print("Fail")
end if

Iteration repeats a block of statements. A definite loop repeats a fixed number of times, an indefinite loop repeats while a condition holds:

for i = 1 to 5
    print(i)
next i

Markers reward correct naming and description of all three, and a valid example of each that clearly shows the structure (ordered statements, a branch, and a repeated block).

CCEA 20225 marksExplain the difference between a definite (count-controlled) loop and an indefinite (condition-controlled) loop, and explain when each should be used.
Show worked answer →

A definite, count-controlled loop repeats a known, fixed number of times, controlled by a counter, for example a for loop running from 1 to 10. You use it when the number of repetitions is known before the loop starts, such as processing every element of a 30-element array.

An indefinite, condition-controlled loop repeats while (or until) a condition is true, and the number of repetitions is not known in advance. A while loop tests the condition before each pass (so it may run zero times); a repeat until loop tests after each pass (so it runs at least once). You use it when repetition depends on data or user input, for example "keep reading numbers until the user enters 0" or "ask for a password until it is correct".

Markers reward the fixed-versus-unknown count distinction, the link to a counter versus a condition, the pre-test versus post-test point for while versus repeat, and a sensible use case for each.

Related dot points

Sources & how we know this