Skip to content

Sequential Program Flow

Executing instructions in-order

Key Concepts

Sequential FlowProgram execution in order, without any variation
Predictable ExecutionWithout any variation is execution, sequential program flow is predictable
Terms
TermMeaning
Code BlockSet of instructions together in a section of a program. Code blocks are instructions that together accomplish a function of the program.
ConditionBoolean value set by data or user input. Can be multiple values that are all logically compared into a single True/False result.
InstructionSingle executable line of code in a program. Includes OpCodes and Operands.

Introduction

A sequential group of instructions (code block) is executing each instruction in order from first to last. Each time the program runs, the code block executes in the same order and with the same results.

Sequential Flow

Without any influence from user or data, a program will execute each instruction in order.

While the program is performing operations on data from user input and/or data stored in memory, it is not jumping around in the code based on the data

Simple sequential program in Java and LC-3 Assembly

java
int result = 0;
int x = 15;
x += 15;
result = x * 2;
LC-3
.ORIG x3000

   LD R2, X
   ADD R2, R2, #15
   ADD R3, R2, R2
   ST R3, Result

   HALT
.END

Result .FILL #0
X .FILL #15

These two code examples run top to bottom with no change in flow

Sequential Flow Diagram

Conclusion

Sequential flow is the default. This occurs with there are no decisions being made in the code.

The contents of this E-Text were developed under an Open Textbooks Pilot grant from the Fund for the Improvement of Postsecondary Education (FIPSE), U.S. Department of Education. However, those contents do not necessarily represent the policy of the Department of Education, and you should not assume endorsement by the Federal Government.
Released under Creative Commons BY NC 4.0 International License