For loop |
In most Imperative programming computer programming languages, a for loop is a control structure which allows code to be execution (computers) iteratively. For loops, unlike while loops, are typically used when the number of iterations is known before entering the loop.
= Examples =
These for loops will calculate the factorial of the number five, 5!, by iterating through all the numbers 1 through 5 and keeping a running product:
== QBasic or Visual Basic ==
Dim factorial As Long : factorial = 1 Dim counter As Integer For counter = 1 To 5 factorial = factorial * counter Next Print factorial
== C programming language or C plus plus ==
unsigned long factorial = 1; for (unsigned int counter = 1; counter|
|