Difference between continue and break statements in C++ Last Updated : 15 Nov, 2022 Summarize Comments Improve Suggest changes Share 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 C++ Programming Language C++ is a computer programming language developed by Bjarne Stroustrup as an extension of the C language. It is known for is fast speed, low level memory management and is often taught as first programming language. It provides:Hands-on application of different programming concepts.Similar syntax to 5 min read Object Oriented Programming in C++ Object Oriented Programming - As the name suggests uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc. in programming. The main aim of OOP is to bind together the data and the functions that operate on them so th 5 min read Decorators in Python In Python, decorators are a powerful and flexible way to modify or extend the behavior of functions or methods, without changing their actual code. A decorator is essentially a function that takes another function as an argument and returns a new function with enhanced functionality. Decorators are 10 min read 30 OOPs Interview Questions and Answers [2025 Updated] Object-oriented programming, or OOPs, is a programming paradigm that implements the concept of objects in the program. It aims to provide an easier solution to real-world problems by implementing real-world entities such as inheritance, abstraction, polymorphism, etc. in programming. OOPs concept is 15 min read Inheritance in C++ The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is one of the most important features of Object-Oriented Programming in C++. In this article, we will learn about inheritance in C++, its modes and types along with the informatio 10 min read Vector in C++ STL C++ vector is a dynamic array that stores collection of elements same type in contiguous memory. It has the ability to resize itself automatically when an element is inserted or deleted.Create a VectorBefore creating a vector, we must know that a vector is defined as the std::vector class template i 7 min read AVL Tree Data Structure An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. Balance Factor = left subtree height - right subtree heightFor a Balanced Tree(for every node): -1 ⤠Balance Factor ⤠1Example of an 4 min read What is a Neural Network? Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamental 12 min read Templates in C++ C++ template is a powerful tool that allows you to write a generic code that can work with any data type. The idea is to simply pass the data type as a parameter so that we don't need to write the same code for different data types.For example, same sorting algorithm can work for different type, so 9 min read C++ Interview Questions and Answers (2025) C++ - the must-known and all-time favourite programming language of coders. It is still relevant as it was in the mid-80s. As a general-purpose and object-oriented programming language is extensively employed mostly every time during coding. As a result, some job roles demand individuals be fluent i 15+ min read Like