Jump Statements
Last Updated: Jan 2026
Jump statements are used to change the normal flow of a program. They make the program “jump” from one part to another instead of running line by line.
C provides two main jump statements:
- break
- continue
- goto
1. break Statement
The break statement stops the loop immediately and exits from it.
✏ Example:
for (int i = 1; i <= 5; i++) {
if (i === 3) {
break; // stops loop when i is 3
}
printf("%d\n",i);
}
💡 Output: 1, 2,
2. continue Statement
The continue statement skips the current iteration and moves to the next one.
Example:
for (int i = 1; i <= 5; i++) {
if (i === 3) {
continue; // skip 3
}
printf("%d\n",i);
}
💡 Output: 1, 2, 4, 5
3. goto Statement
The goto statement allows you to jump to a specific label in the program.it always end with a label :.
Example:
int main() {
int x = 10;
int y = 20;
if (x > y) {
goto label1;
} else {
goto label2;
}
label1:
printf("x is greater than y\n");
return 0;
label2:
printf("x is less than or equal to y\n");
return 0;
}
💡 Quick Practice
- Write a loop from 1-10 and stop the loop when number is 6.
- Print all numbers from 1-10 except 4 and 8 using continue.
- Exercises Set
