CJCoding With Joseph
← Back to Question List
C++ Code Walkthrough #35

For Loop with Break

easyLoops

📄 Code

Read carefully — what does this print?
1#include <iostream>
2using namespace std;
3int main() {
4 int sum = 0;
5 for (int i = 1; i <= 10; i++) {
6 if (i == 5) break;
7 sum += i;
8 }
9 cout << sum << endl;
10 return 0;
11}

🎯 Your Answer