|
|
coherent
for C Keyword for
Control a loop
ffoorr(_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
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.