C++ Tutorial · Chapter 9 of 13
C++ For Loop
Counted repetition.
for loops are common for counting and visiting array indexes.
Nested loops help build patterns and tables.
For sample
Try it Yourself »
#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 5; i++) {
cout << i << endl;
}
return 0;
}
Classroom Tips
- Check loop limits carefully.