Programming Constructs
There are THREE basic programming constructs. They are:
- SEQUENCE
- SELECTION
- ITERATION
SEQUENCE
Sequence logic is used for performing instructions one after another in sequence.
- Sequence is the most basic of the constructs
- It is simply performing one step after another
- Each step is followed in a specific sequence, hence the name
- Sequence can be thought of as “do this, then do this, then do this”
SELECTION
Selection logic, also known as decision logic, is used for making decisions. Selection logic is depicted as either an IF…THEN…ELSE or IF…..THEN structure.
- Selection is the decision-making construct.
- It is used to make yes/no or true/false decisions logically.
- Selection can be thought of as “if something is true, take this action, otherwise take that action”.
ITERATION
Iteration logic is also known as Loop. Iteration logic is used when one or more instructions may be executed several times depending on some condition.
- Iteration comes from the word “reiterate”, which means to repeat
- Iteration is a looping construct
- Iteration is a combination of decision and sequence and can repeat steps
- Iteration can be thought of as “while something is true, do this, otherwise stop”