Sometimes a loop should stop early (the answer has been found) or skip one item (an invalid record) without stopping. C’s jump statements break and continue do this. The older goto statement can jump almost anywhere in a function and is generally avoided.
break
break immediately ends the innermost enclosing loop (or switch); execution continues with the first statement after it.
In nested loops, break leaves only the loop it is in, not the outer loops. break is different from the library function exit(), which ends the whole program.
continue
continue skips the rest of the current repetition and starts the next one:
In a while or do–while loop, control goes to the condition test.
In a for loop, control goes to the update part, then to the condition.
goto and labels
goto label; transfers control to the statement marked label: in the same function. A label is an identifier followed by a colon.
goto makes programs hard to follow (the “spaghetti code” of Unit 1). Structured statements (if, loops, break, continue, functions) can do everything it does. Its one accepted use is jumping out of deeply nested loops to a single exit or clean-up point.
Comparison
Statement
Effect
Used in
break
Leaves the innermost loop or switch
Loops, switch
continue
Skips to the next repetition (via the update in for)
Loops only
goto label
Jumps to a labelled statement in the same function
Anywhere in a function (avoid)
exit(n)
Ends the whole program
Anywhere (library function in <stdlib.h>)
Key takeaways
break ends the innermost loop or switch immediately.
continue ends the current repetition; in for loops, the update still runs.
goto jumps to a label in the same function; structured code avoids it.
exit() ends the whole program, unlike break.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Explain the difference between break and continue using a loop that runs i from 1 to 5 and tests i == 3, giving the output of each version.
Show worked answer
With for (i = 1; i <= 5; i++) { if (i == 3) break; printf("%d ", i); }, the loop stops completely when i is 3, so the output is 1 2. With continue instead of break, only the repetition for 3 is skipped and the loop carries on, so the output is 1 2 4 5. break leaves the loop; continue moves on to the next value.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-201/decision-and-loop-control-statements/jump-statements-break-continue-and-goto/ to read this page.