When designing algorithms, there are many steps where decisions must be made. This decision is known as selection, and can be displayed in pseudocode or flow diagrams.
A flow diagram (also known as a flowchart) is a diagram that explains the steps of an algorithmA sequence of logical instructions for carrying out a task. In computing, algorithms are needed to design computer programs..
Consider this simple six-step algorithm for comparing your dog’s age with your own:
ask how old the dog is in human years
multiply human years by seven to find out how old the dog is in dog years
print answer on the screen
ask how old you are
if the dog’s age in dog years is older than your age, say ‘Your dog is older than you!’
otherwise, say ‘Your dog is not older than you.’
In a flow diagram, this sequence would look like this: