Last Updated : 11 Jul, 2025
Break and continue are same type of statements which is specifically used to alter the normal flow of a program still they have some difference between them.
break statement: the break statement terminates the smallest enclosing loop (i. e., while, do-while, for or switch statement)
continue statement: the continue statement skips the rest of the loop statement and causes the next iteration of the loop to take place.
an example to understand the difference between break and continue statement
CPP
// CPP program to demonstrate difference between
// continue and break
#include <iostream>
using namespace std;
main()
{
int i;
cout << "The loop with break produces output as: \n";
for (i = 1; i <= 5; i++) {
// Program comes out of loop when
// i becomes multiple of 3.
if ((i % 3) == 0)
break;
else
cout << i << " ";
}
cout << "\nThe loop with continue produces output as: \n";
for (i = 1; i <= 5; i++) {
// The loop prints all values except
// those that are multiple of 3.
if ((i % 3) == 0)
continue;
cout << i << " ";
}
}
Output:
The loop with break produces output as: 1 2 The loop with continue produces output as: 1 2 4 5
Description of the program:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4