Lesson 17Control Flow
For Loops
Learn about for loops in C++ programming!
main.cpp
#include <iostream>
using namespace std;
int main() {
// Count from 1 to 5
for (int i = 1; i <= 5; i++) {
cout << "Count: " << i << endl;
}
// Loop through an array
int numbers[] = {10, 20, 30, 40, 50};
for (int num : numbers) {
cout << "Number: " << num << endl;
}
return 0;
}