Description
The for
statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop. The for
statement is useful for any repetitive operation, and is often used in combination with arrays to operate on collections of data/pins.
Syntax
for (initialization; condition; increment) {
//statement(s);
}
The initialization happens first and exactly once. Each time through the loop, the condition is tested; if it’s true
, the statement block, and the increment is executed, then the condition is tested again. When the condition becomes false
, the loop ends.