# Difference between break and continue statement in C

• Difficulty Level : Easy
• Last Updated : 27 Mar, 2021

In this article, we will discuss the difference between the break and continue statements in C. They are the same type of statements which is used to alter the flow of a program still they have some difference between them.

break statement: This statement terminates the smallest enclosing loop (i.e., while, do-while, for loop, or switch statement). Below is the program to illustrate the same:

## C

 `// C program to illustrate the``// break statement``#include `` ` `// Driver Code``int` `main()``{`` ` `    ``int` `i = 0, j = 0;`` ` `    ``// Iterate a loop over the``    ``// range [0, 5]``    ``for` `(``int` `i = 0; i < 5; i++) {`` ` `        ``printf``(``"i = %d, j = "``, i);`` ` `        ``// Iterate a loop over the``        ``// range [0, 5]``        ``for` `(``int` `j = 0; j < 5; j++) {`` ` `            ``// Break Statement``            ``if` `(j == 2)``                ``break``;`` ` `            ``printf``(``"%d "``, j);``        ``}`` ` `        ``printf``(``"\n"``);``    ``}`` ` `    ``return` `0;``}`
Output:
```i = 0, j = 0 1
i = 1, j = 0 1
i = 2, j = 0 1
i = 3, j = 0 1
i = 4, j = 0 1
```

Explanation: In the above program the inner for loop always ends when the value of the variable j becomes 2.

continue statement: This statement skips the rest of the loop statement and starts the next iteration of the loop to take place. Below is the program to illustrate the same:

## C

 `// C program to illustrate the``// continue statement``#include `` ` `// Driver Code``int` `main()``{`` ` `    ``int` `i = 0, j = 0;`` ` `    ``// Iterate a loop over the``    ``// range [0, 5]``    ``for` `(``int` `i = 0; i < 5; i++) {`` ` `        ``printf``(``"i = %d, j = "``, i);`` ` `        ``// Iterate a loop over the``        ``// range [0, 5]``        ``for` `(``int` `j = 0; j < 5; j++) {`` ` `            ``// Continue Statement``            ``if` `(j == 2)``                ``continue``;`` ` `            ``printf``(``"%d "``, j);``        ``}`` ` `        ``printf``(``"\n"``);``    ``}`` ` `    ``return` `0;``}`
Output:
```i = 0, j = 0 1 3 4
i = 1, j = 0 1 3 4
i = 2, j = 0 1 3 4
i = 3, j = 0 1 3 4
i = 4, j = 0 1 3 4
```

Explanation: In the above program the inner for loop always skip the iteration when the value of the variable j becomes 2.

Tabular Difference Between the break and continue statement:

My Personal Notes arrow_drop_up