The break statement is used to exit or terminate a loop prematurely. When encountered inside a loop (such as for, while, or do-while), the break statement immediately terminates the loop and transfers control to the next statement outside the loop.
Example:
for (int i = 0; i < 10; i++) {
if (i == 5) {
break; // Exit the loop when i equals 5
}
cout << i << " ";
}
// Output: 0 1 2 3 4