C++20 sections · 1024 units
Open in Course

Counting Up

Standard forward iteration

Counting up starts at a low value and increases each iteration. You use i++ or i += step to move forward through your range. Example: for (int i = 1; i <= 10; i++) counts 1 through 10.

The condition i <= 10 includes 10 in the output because the check uses less-than-or-equal. You can start at any value: for (int i = 5; i < 15; i++) counts 5 through 14. The loop exits when i reaches 15 because the condition becomes false.