Skip to content

Repeating with for

Read · 1 of 5

A for loop has three parts

for (int i = 1; i <= 5; i++) { … } means: start with i = 1, keep going while i <= 5, and after each round step i up by one.

The code in braces (the body) runs once per round.