C++20 sections · 1024 units
Open in Course

The Initialization Part

Starting the loop

The initialization part declares and initializes the loop counter. It runs exactly once before the first iteration begins. You typically declare the counter here: for (int i = 0; .).

The variable i only exists inside the for loop scope and cannot be used after the loop ends. You can initialize multiple variables: for (int i = 0, j = 10; .). Separate them with commas.

Both variables are local to the loop and disappear when it ends.