The short answer
Sequencing in programming means each statement runs in turn, from the top of the program to the bottom. A statement finishes before the next one starts. Unless a control structure changes the flow, the program does not skip ahead or go back.
A worked example
Consider this Python program:
name = "Sam"
score = 42
score = score + 8
print(name, "scored", score)
Trace it one line at a time:
| Step | Statement | Values after the step |
|---|---|---|
| 1 | name = "Sam" |
name is "Sam" |
| 2 | score = 42 |
score is 42 |
| 3 | score = score + 8 |
score is 50 |
| 4 | print(...) |
Prints Sam scored 50 |
Each row depends on the rows above it. Line 3 uses the value of score that line 2 set. That dependence is why the order matters.
Why the order of lines matters
Suppose the line that adds 8 came before the line that sets score. Python would stop with a NameError, because score would not exist yet. The same lines in a different order can produce an error or a different result.
Sequence in pseudocode and flowcharts
Pseudocode and flowcharts show the same idea. In pseudocode, steps are numbered or listed in the order they happen. In a flowchart, boxes connect with arrows in that same order. A purely sequential flowchart is a straight path with no branches.
When the order changes
Sequencing is the default, but programs often need to choose between paths or repeat steps. Those are selection and iteration. For the choice case, see what is selection in computer science. For the bigger picture of how these structures fit together, see what is sequencing in computer science.
Common beginner mistakes
- Using a variable before it has been assigned a value.
- Expecting a line inside an
ifblock to run when the condition is false. - Reading a program as a whole instead of line by line, which hides which value each line actually sees.
Summary
Sequencing means running statements one at a time, in the order they are written. Tracing a program line by line, and noting the value of each variable after each step, is a reliable way to see what the program does.