Let us have a look at C Jump Statements
Let’s examine the break and continue jump statements in C program. These statements are used to change the switch statement’s and loops’ typical sequential execution flow.
Jump statements like break, continue, and goto offer less structured methods of transferring control, even though sequence, selection (if, if-else, switch), and iteration (while, do-while, for) are the usual methods used in structured programming to manage flow control. Break and continue are ubiquitous and can occasionally simplify code or enhance efficiency, but they can also make programs more difficult to read or debug when compared to fully organised techniques.
C Jump Statements (break and continue)
You can skip portions of a loop body or end a loop or switch statement early by using the break and continue statements.
The break Statement
A switch statement or the innermost enclosing loop (while, do-while, or for) can be terminated with the break statement. Control instantly leaves the loop or switch and moves on to the next statement when break is invoked.
Use in Loops: Break, which is frequently condition-based, results in an early loop exit. A break only leaves the innermost loop when it is performed inside a nested loop structure. The loop’s subsequent iterations and the statements that follow the break are omitted.
- The break syntax is just break;. There are no operands for it.
- A for loop break example would be:
- The loop in this example is intended to run ten times, but the program instantly exits the for loop when i reaches five because the if condition is true and the break statement is performed. Following the loop, the printf statement is then run.
Break Statement with loop
#include <stdio.h>
int main(){
// Using break inside for loop to terminate
// after 2 iterations
printf("break in for loop\n");
for (int i = 1; i < 5; i++) {
if (i == 3) {
break;
}
else {
printf("%d ", i);
}
}
// using break inside while loop to terminate
// after 2 iterations
printf("\nbreak in while loop\n");
int i = 1;
while (i < 20) {
if (i == 3)
break;
else
printf("%d ", i);
i++;
}
return 0;
}
break in for loop
1 2
break in while loop
1 2
Use in switch Statements: For switch statements to avoid “fallthrough,” breaks are necessary. Whether or not the value of the switch expression matches the case label, if there is no break at the end of a case’s statements, execution will proceed into the subsequent case’s statements. One typical logical error with switches is to forget to include a break when one is required.
- An illustration of a switch statement break:
- Because execution would move on to the next case label and continue running its instructions until a break or the end of the switch was met, if the break statement was absent from case ‘b’ and choice was ‘b’, the program would print “Selected B” before failing and printing “Selected C”.
Break Statement with Switch
#include <stdio.h>
#include <stdlib.h>
int main() {
char c;
float x, y;
while (1) {
printf("Enter an operator (+, -), if want to exit "
"press x: ");
scanf(" %c", &c);
// to exit
if (c == 'x')
exit(0);
printf("Enter Two Values:\n ");
scanf("%f %f", &x, &y);
switch (c) {
// For Addition
case '+':
printf("%.1f + %.1f = %.1f\n", x, y, x + y);
break;
// For Subtraction
case '-':
printf("%.1f - %.1f = %.1f\n", x, y, x - y);
break;
default:
printf(
"Error! please write a valid operator\n");
}
}
}
Enter an operator (+, -), if want to exit press x: +
Enter Two Values:
10
20
10.0 + 20.0 = 30.0
The continue Statement

Only while, do-while, or for loops use the continue statement. For the current iteration, it skips the remaining statements in the loop’s body and moves straight on to the next one.
Use in Loops: Control immediately moves to the loop-continuation condition test in while and do-while loops when continue is executed.
- Control moves to the loop expression (the increment/decrement portion) in a for loop when continue is conducted. The loop-continuation condition test is then performed after the loop expression is executed.
- In the loop body, continue is usually used to continue the loop for other values while avoiding processing steps for certain values or situations.
- The simple syntax for “continue” is “continue;.”
- A switch statement cannot use continue.
- An illustration of a for loop’s continue:
- In this example, the if condition is true and continue is carried out when i is 4, 5, 6, 7, or 8. For those values of i, this results in the printf statement being skipped, and control is passed straight to the i++ section of the for loop header for the subsequent iteration.
Continue Statement Example
#include <stdio.h>
int main()
{
int i;
// loop
for (i = 0; i < 5; i++) {
if (i == 2) {
// continue to be executed if i = 2
printf("Skipping iteration %d\n", i);
continue;
}
printf("Executing iteration %d\n", i);
}
return 0;
}
Executing iteration 0
Executing iteration 1
Skipping iteration 2
Executing iteration 3
Executing iteration 4
In conclusion, continue skips the remainder of the current loop iteration and advances to the next one, whereas break exits the whole loop or switch. They can be quite effective in regulating flow, but in order to preserve code clarity, their use should be carefully chosen.