CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

For Loop with Break

C++ code walkthrough · Question 35
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