2.3 The Struture Theorem
The Struture Theorem revolutionized program design by establishing a structured framework for representing a solution algorithm. The Struture Theorem states that it is possible to write any computer program by using only three basic control Strutures that are easily represented in pseudocode.
The three basic control structures
1. Sequence
The sequence control structure is the straightforward execution of one processing step after another. In pseudocode, we represent this construct as a sequence of pseudocode statemants.
Statemants a
Statemants b
Statemants c
The sequence control structure can be used to represent the first four basic computer operations listed previously to receive information , put out information, perform arithmetic , and assign values. For example, a typical sequence of statements in an algorithm might read:
Add 1 to pageCount
Print heading line1
Print heading line2
Set lineCount to zero
Read customer record
These instructions illustrate the sequence control structure as a straightforward list of steps written one after the other, in a top-to-bottom fashion. Each instruction will be executed in the order in which it appears.
2. Selection
The selection control struture is the presentation of a condition and the choice between two actions, the choice depending on whether the condition is true or false. This construct represents the decision-making abilities of the computer and is used to illustrate the fifth basic computer two variables and select one of two alternate actions.
In pseudocode , selection is represented by the keywords IF,THEN,ELSE, and ENDIF :
IF condition p is true THEN
Statement(s) in true case
ELSE
Statement(s) in false case
ENDIF