Summary: The for Statement

I l @ ve RuBoard

Summary: The for Statement

Keyword

The for statement keyword is for .

General Comments

The for statement uses three control expressions, separated by semicolons, to control a looping process. The initialize expression is executed once, before any of the loop statements are executed. If the test expression is true (or nonzero), the loop is cycled through once. Then the update expression is evaluated, and it is time to check the test expression again. The for statement is an entry-condition loop; the decision to go through one more pass of the loop is made before the loop has been traversed. Therefore, it is possible that the loop is never traversed. The statement part of the form can be a simple statement or a compound statement.

Form

 for (  initialize ; test ; update  )  statement  

The loop is repeated until test becomes false or zero.

Example

 for (n = 0;  n < 10 ; n++)       printf("%d %d\n", n, 2 * n+1); 
I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net