Sequence Control Structures
A sequence control structure is a type of control structure that executes a series of statements in a specific order, one after the other — like following a recipe step by step. For example, making tea: boil water, add tea leaves, stir, pour into cup. Changing the order of the statements would result in a different outcome (e.g., adding tea leaves before boiling water).
Selection Control Structures
A selection control structure is a type of control structure that allows a program to choose between two or more alternative paths based on a condition — like being at a crossroads and deciding which path to take.
Example: determining the cost of shipping an item:
- If weight ≤ 1kg, then cost = 500frs
- Else, if weight ≤ 5kg, then cost = 1000frs
- Else, cost = 2000frs
Example: determining the area of a rectangle using selection:
- Input length and width
- If length == width, then Area = length x width (square)
- Else, Area = length x width (rectangle)
- Output Area