Flowcharts
Flowcharts are used to show the flow of a procedure in an application. An application depending on its
complexity may have several flowcharts. The general practice today among many programmers is to
ignore this crucial step in the development of a system. However, careful planning and design of a
system has been shown to prevent crucial situations down the road.
You’re driving down the QEW, the following is a flowchart of some of your activities.
Start
Check
Speedometer
Is Speed over Yes Slow
100 km/h? Down
No
Continue
Driving
End
Here are some of the main components of a flowchart:
Start/End Symbol – This is used at the beginning or end of a flowchart.
Input/Output Box – Used to show data entry or screen output.
Statement Box – Used to show the expressions in the flowchart.
Decision Box – Used to show when there is a choice or decision to be made.
Flow Lines – These lines connect the components together. Arrows show the direction of the logical flow
of the program. If there is no arrow on a line, the flow is assumed to go left to right for horizontal lines
and top to bottom for vertical lines.
Flowchart Rules
All flowcharts must have a single start and a single end.
All boxes (except for start and end) must have a flow line entering and a flow line leaving
that box.
Only a decision box can have two flow lines leaving it.
If there are more than two outcomes to a decision, the decision box must be broken up into
two or more decision boxes.
Default actions should be placed vertically (top to bottom) in the flowchart. It is the
exceptions, which should branch off horizontally.
For good readability try to design your flowchart top-to-bottom and left-to-right.
Branches and Loops
When we come to a decision point in a flowchart the route taken can be any one of the possible
outcomes. This is known as branching.
If a branch takes us back in the flowchart so that a particular decision is encountered again and
again, this type of branch is known as a loop. We must ensure that at least one of the outcomes
will take us out of the loop, otherwise the program will go in circles forever. This scenario is
known as a continuous or endless loop.
Flowchart Example
We will now create a flowchart. The following example is given in everyday language. Construct the
flowchart step-by-step.
Example:
Every morning during the winter, Lucy looks out the window to check out the weather. If it is snowing,
she puts on her snow boots. If it is raining, she takes out the umbrella. Since it is cold she always takes
her coat. She then leaves the home.
Start
Check out the
weather
Is it Yes Put on Boots
Snowing?
No
Is it Yes Take umbrella
Raining?
No
Put on coat
Leave home
End
Example 1:
Peter goes through the same routine every morning. The alarm rings at 6:00 am, he presses the snooze
button. This delays getting up for another 6 minutes. Every time the alarm rings thereafter, he checks to
see if it is 7:00 am and presses the snooze button again. He continues this ritual until 7:00 am when he
promptly gets out of bed.
Example 2:
Draw a flowchart to report whether a number is odd or even. (A number evenly divisible by 2 is even)
Example 3:
Draw a flowchart to find the larger of 2 numbers. Call them X and Y. Test your flowchart with the
numbers 8 and 3, 2 and 9, 7 and 7.