For, While, and Do-While
C++ supports for, while, and do-while loops, plus range-based for loops (C++11).
Example
// For loop
for (int i = 0; i < 5; i++) {
cout << i << " ";
}
// 0 1 2 3 4
// While loop
int count = 0;
while (count < 5) {
cout << count << " ";
count++;
}
// Do-while
int n;
do {
cout << "Enter positive number: ";
cin >> n;
} while (n <= 0);
// Range-based for loop (C++11)
int arr[] = {10, 20, 30, 40, 50};
for (int num : arr) {
cout << num << " ";
}
// break and continue
for (int i = 0; i < 10; i++) {
if (i == 5) break; // stop at 5
if (i % 2 == 0) continue; // skip even
cout << i << " "; // 1 3
} 