In this tutorial, we will learn For loop statement in Flowgorithm flowchart. Loop structure in a flowchart executes a set of statements or instructions multiple times based on some conditions.
For loop is a repetitive structure. A For loop is a definite loop. It is best suited when we know how many times we need to run the loop.
To add the For loop construct, right click the mouse on the control line and choose the For symbol.
To define the loop construct double click on the for symbol. This will launch the For Properties window. Fill this window with the For loop properties. These properties decide how the For loop will run.
The variable name used for the For loop iterations.
The initial value of the For loop variable.
The end value of the For loop variable. The For loop terminates when the loop variable reaches this value.
Increasing / Decreasing
Loop variable Step value. The value of the loop variable to be increased/decreased for the next iteration.
Let’s take a simple example to print numbers from 1 to 20 to the console window. Imagine without For loop we have to use the Output statements 20 times in the flowchart to print the numbers.
Define a loop variable : counter.
Add a For loop.
Define the Loop structure as shown.
In the loop add an Output statement to print the value of the loop variable : counter.
Execute the flowchart.