Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


for                         C Keyword                         for




Control a loop

for(initialization; endcondition; modification)

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


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026