Assuming standard headers and using namespace std, what does this C++ code print? int s = 0; for (int i = 1; i <= 10; i++) { if (i % 3 == 0) continue; if (i > 7) break; s += i; } cout << s;
Correct answer C. 19
Explanation
The loop skips multiples of 3 with continue, so i = 3 and 6 are never added. At i = 8 the break leaves the loop entirely. The values added are 1, 2, 4, 5 and 7, giving 19. Remember that continue jumps to the next iteration (running i++), while break exits the loop at once.
Answer checked How we write and check questions
Discussion