The for operator consists of three expressions and an executable operator:

for(expression1; expression2; expression3)

Expression1 describes the loop initialization. Expression2 checks the situations of the loop termination. Whether it is true, the loop physique for is executed. The loop repeats expression2 till it turns into false. Whether it is false, the loop is terminated, and management is given to the subsequent operator. Expression3 is calculated after every iteration.

The for operator is equal to the next succession of operators:



Any of the three or all three expressions might be absent within the for operator, however the semicolons (;) that separate them should not be omitted. If expression2 is omitted, it’s thought-about consistently true. The for(;;) operator is a steady loop, equal to the whereas(1) operator. Every expression 1 or three can include a number of expressions mixed by a comma operator ‘,’.



for(x=1;x<=7000; x++)
//— One other instance
   if(x>10) break;
//— Third instance
for(i=0,j=n-l;iIsStopped();i++,j–) a[i]=a[j];

See additionally

Initialization of Variables, Visibility Scope and Lifetime of Variables, Creating and Deleting Objects

Leave a Reply

Your email address will not be published. Required fields are marked *