8.3 Representing for Loops in Flowcharts

Most programs include some form of iteration or looping. One of the easiest ways to create a loop in a C program is by using the for statement. This section shows how a for loop can be represented in a flowchart. As shown below, there are several methods of representing a for loop in a flowchart.

Suppose that we have a for loop as below and we wish to draw an equivalent flowchart.

img

Method 1

Figure 8.14 shows one of the methods for representing the above for loop as with a flowchart. Here, the flowchart is drawn using the basic primitive components.

Method 2

Figure 8.15 shows the second method for representing the for loop with a flowchart. Here, a hexagon shaped flowchart symbol is used to represent the for loop and the complete for loop statement is written inside this symbol.

Method 3

Figure 8.16 shows the third method for representing the for loop with a flowchart. Here again, a hexagon shaped flowchart symbol is used to represent the for loop and the symbol is divided into three to represent the initial condition, the increment, and the terminating condition.

Figure 8.14 Method 1 for representing a for loop

img

Figure 8.15 Method 2 for representing a for loop

Figure 8.16 Method 3 for representing a for loop

Get Using LEDs, LCDs and GLCDs in Microcontroller Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.