The first and simplest of the types of control flow is sequence: the following of one operation by another operation. In the factorial flowchart, the two boxes after the test (“a > n”) are a sequence:
These two steps are to be carried out in the order shown: otherwise, the product b, instead of becoming n × n-1 × n-2 × ... × 1, could be n × n × n-2 × n-2 × ... × 1. Generally, flowcharts use sequencing to indicate a mandatory order of computations, as in this case. However, sometimes separate boxes are used when they are not strictly necessary.
Programs, however, generally impose an evaluation order simply through the rules of the language. A program is linear text, and one statement must of necessity come before another statement. This sequencing might or might not be necessary. There are languages in which it is possible to write unsequenced statements, but these languages are rarely used.
Copyright © 2001 Brian Hetrick
Page last updated 30 December 2001.
Building Blocks I
Control Flow I
Control Flow II
A First Program
Data Structures I
Building Blocks II
Data Structures II