Jump Statements in C
C provides three primary jump statements — break, continue, and goto — that unconditionally transfer execution to another statement, altering standard loop or branching flow.
break statement runs inside a nested loop?The break Statement
The break statement terminates the enclosing loop (`for`, `while`, `do-while`) or `switch` block immediately. Execution jumps to the statement following the loop body.
Interactive Search Lab: Array Linear Search
Search for a target value in array [15, 28, 42, 73, 91]:
The continue Statement
The continue statement skips the remainder of the current loop iteration and jumps directly to the update expression (in `for` loops) or condition evaluation (in `while` loops).
Interactive Data Filter Lab
Sum only positive numbers from array [10, -5, 20, -8, 30]:
break vs continue at a Glance
Understanding how `break` and `continue` alter execution flow inside loop structures.
The `break` Statement
Action: Terminates the loop completely and exits immediately.
Loop stops at 3. Iterations 3, 4, 5 are NEVER executed.
The `continue` Statement
Action: Skips only the current iteration and moves to the next cycle.
Only iteration 3 is skipped. Iterations 4 and 5 execute normally.
The goto Statement & Statement Labels
The goto statement transfers execution unconditionally to a specified statement label within the same function.
Label Definition Syntax
A label is an identifier followed by a colon (label_name:). The goto statement jumps directly to it.
Forward vs Backward Jumps
Jumping forward skips intervening statements. Jumping backward creates custom loop structures (which can cause infinite loops!).
Label Scope Rule
A label is visible throughout the entire function in which it is defined, but cannot be jumped to from a different function!
Escaping Nested Loops with goto
A single `break` statement only exits the innermost loop. `goto` provides a clean way to jump out of deeply nested loops when an error or target condition occurs.