For loops

A for statement is a concise way to write the initialization, condition, and increment of a loop statement.

for loopshow initializationshow conditionshow increment
for (initialization ; condition ; increment) { ... }

A common use of a for loop is to concisely express the iteration of a while loop, as shown below.

Was this page helpful?