Labs ICT
โญ Pro Login

Break & Continue

break and continue

Two jump statements give you finer control inside loops.

break exits the loop immediately. Execution jumps to the line after the loop.

continue skips the rest of the current iteration and moves to the next one.

for (int i = 1; i <= 10; i++) {
  if (i == 5) {
    break;
  }
  if (i % 2 == 0) {
    continue;
  }
  cout << i << "\n";
}

In this example, continue skips even numbers, and break stops the loop entirely when i reaches 5. The output is 1 and 3.

Try it Yourself โ†’

๐Ÿงช Quick Quiz

What does the continue statement do in a loop?