Difference between continue and break statements in C++ Last Updated : 15 Nov, 2022 Comments Improve Suggest changes Like Article Like Report 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: Now when the loop iterates for the first time, the value of i=1, the if statement evaluates to be false, so the else condition/ statement is executed.Again loop iterates now the value of i= 2, else statement is implemented as if statement evaluates to be false.Loop iterates again now i=3; if the condition evaluates to be true and the loop breaks.Now when the loop iterate for the first time then the value of i=1, the if statement evaluates to be false, so the else condition/ statement 2 is implemented.Again loop iterates now the value of i= 2, else statement is implemented as if statement evaluates to be false.Loop iterates again now i=3; if the condition evaluates to be true, here the code stop in between and start new iterate until the end condition met. Comment More infoAdvertise with us Next Article Difference between continue and break statements in C++ M MinalJain Follow Improve Article Tags : Technical Scripter C++ Programs C++ Practice Tags : CPP Similar Reads Why Breaks are used in C++ Switch Statement? In C++, the switch statement allows us to select a code block to be executed based on some conditions among many alternatives (listed in the form of cases). The break keyword plays an important role in the functioning of a switch statement. In this article, we will learn why breaks are used in C++ s 2 min read How Do I Continue to the Next Iteration of a for Loop After an Exception is Thrown in C++? In C++, when an exception is thrown, the normal flow of the program is disrupted and we need to take care of it. In this article, we will learn how can we continue to the next iteration of a for loop after an exception is thrown in C++. Continue Loop After an Exception is Thrown in C++To continue to 2 min read How to Use the Try and Catch Blocks in C++? In C++, the try and catch blocks are used as a part of the exception handling mechanism which allows us to handle runtime errors. If the exceptions are not handled properly then the flow of the program is interrupted and the execution might fail. In this article, we will learn how to use try and cat 2 min read How to Throw and Catch Exceptions in C++? In C++, exception handling is a mechanism that allows us to handle runtime errors and exceptions are unusual conditions that occur at runtime. In this article, we will learn how to throw and catch exceptions in C++. Throw and Catch Exceptions in C++In C++ exceptions can be "thrown" when an error occ 2 min read How to Utilize the goto Statement in C++? The goto statement in C++ is a control flow statement that allows the users to move the control flow from one part to another part of the program. In this article, we will learn how to utilize the goto statement in C++. Utilize the goto Statement in C++In C++, the goto statement transfers the progra 2 min read Like