COHERENT manpages

This page displays the COHERENT manpage for for [Control a loop].

List of available manpages
Index


for -- C Keyword

Control a loop
for(initialization; endcondition; modification)

for is a C keyword that introduces a loop.  It takes three arguments, which
are  separated by  semicolons `;'.  initialization  is executed  before the
loop  begins.  endcondition  describes the  condition  that ends  the loop.
modification is a statement that modifies variable to control the number of
iterations of the loop.  For example,

    for (i=0; i<10; i++)

first sets  the variable  i to  zero; then it  declares that the  loop will
continue as long  as i remains less than ten;  and finally, increments i by
one after  every iteration of  the loop.  This  ensures that the  loop will
iterate exactly ten times (from i==0 through i==9). The statement

    for(;;)

will loop  until its execution is  interrupted by a break,  goto, or return
statement.   Also, either  or both of  initialization and  modification may
consist of multiple statements that are separated by commas.  For example,

    for (i=0, j=0; i<10; i++, j++)

initializes both  i and j, and  increments both with each  iteration of the
loop.

See Also

break,
C keywords,
continue,
while
ANSI Standard, §6.6.5.3