#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 10; i++) {
cout << i << endl;
if (i == 5) {
break;
}
}
return 0;
}
- Include input/output stream library.
- Use the standard namespace.
- Define the main function.
- Begin a for loop with an integer variable i initialized to 0, with a condition for i being less than 10, and an increment of i after each iteration.
- Print the value of i followed by a new line.
- Check if the value of i is equal to 5.
- If i is equal to 5, exit the for loop.
- Return 0, as the main function is an int type.
```