Menu

Flowcharts

Sub Programs in Flowcharts

A sub program symbol is a rectangle with an extra short vertical line just inside each of its sides. It means “run the named sub program at this point”, and the name written inside tells you which one to run.

A sub program is not drawn inside the main flowchart. It is drawn as its own separate flowchart. That flowchart begins with a terminal containing the sub program’s name and ends at a Stop terminal. For example, a main flowchart for a quiz game might have a sub program symbol labelled displayResult. The separate displayResult flowchart starts with a terminal reading displayResult, shows the score, then reaches Stop.

Using the symbol keeps a large flowchart manageable. You can break the algorithm into smaller, separate flowcharts, so each part is easier to design, read, test and understand. The main flowchart shows when the sub program runs; the sub program’s own flowchart shows what happens when it runs.

SymbolWhat it doesWhere the steps are drawn
Process rectangleSets or changes a valueIn the same flowchart
Sub program rectangle with side linesRuns a named sub programIn its own separate flowchart

The two are easy to mix up: a process rectangle sets or changes a value in the flowchart you are already reading, while a sub program symbol sends you to a different flowchart.

Practise this