How do I use for loop statement?
Category: Introduction, viewed: 150 time(s).
The for loop executes a statement or a block of statement repeatedly until the expression specified in the loop statement equals to false. This loop is useful for iterating an array variable or doing a sequential processes.
The example above (we take the outer loop) can be explained as follow:
- First, initialize the
ivariable with zero, this means our loop start from zero. - Second, the
forloop check whetherihas the value less than 10 and execute the block if it is true. - Third, increment the
ivariable. The loop will be reevaluated whether the condition still true. If it is false the control will go outside the loop.
The result of our loop above is:
* ** *** **** ***** ****** ******* ******** ********* **********
Download Hundreds of Complimentary Industry Resources
Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more;
all available at no cost to you. With more than 600 complimentary offers, you'll find
plenty of titles to suit your professional interests and needs.
Click Here and Sign up today!