Not only allowed, but encouraged.
Here is the syntax of the for
statement:
for ( initialize ; condition; bottom ) body
Almost always the body is a code block:
for ( initialize ; condition; bottom ) { body }
The flowchart at left shows the operation of a for
statement.
The Universal Flowchart is repeated, at right.
It is clear from these charts that the for
loop nearly embodies all the
parts of the Universal Flowchart.
All that is missing is the finalize block.
So using a for
statement in your program is a neat way to implement
the Universal Flowchart as part of your solution.
Sometimes, in fact, the body of a C function will consist entirely of a fleshed-out for
loop.
Where, in both of these looping structures, is the condition tested?