

for                         C Keyword                         for




Control a loop

ffoorr(_i_n_i_t_i_a_l_i_z_a_t_i_o_n; _e_n_d_c_o_n_d_i_t_i_o_n; _m_o_d_i_f_i_c_a_t_i_o_n)

for is  a C keyword that  introduces a loop.  It  takes three ar-
guments, 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 en-
sures 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
















COHERENT Lexicon                                           Page 1


