Break Statement in C
We’ll cover break, continue, and goto (briefly), with clear examples.
Loop control statements are used to:
- Change the normal flow of a loop
- Stop a loop early
- Skip certain iterations
They give extra control over loops.
1. break Statement
What break does
- Immediately terminates the loop
- Control goes outside the loop
Example
c
1
2#include <stdio.h>
3
4int main() {
5 int i;
6
7 for (i = 1; i <= 5; i++) {
8 if (i == 3)
9 break;
10 printf("%d ", i);
11 }
12
13 return 0;
14}Output
1 2Explanation
- Loop stops when
i == 3 - Remaining iterations are skipped
