for loop
for loop
(programming)In C, the for loop is written in the form;
for (INITIALISATION; CONDITION; AFTER)STATEMENT;
where INITIALISATION is an expression that is evaluated oncebefore the loop, CONDITION is evaluated before each iterationand the loop exits if it is false, AFTER is evaluated aftereach iteration, and STATEMENT is any statement including acompound statement within braces ".." that is executed ifCONDITION is true.
For example:
int i;for (i = 0; i < 10; i++)printf
prints "Hello" 10 times.
The for loop is an alternative way of writing a while loopthat is convenient because the loop control logic is collectedin a single place. It is also closely related to the repeat loop.