🟡 Control Flow · Lesson 20
break and continue Statements
break and continue Statements
What is break and continue Statements?
break and continue Statements
break stops a loop immediately. continue skips the current iteration and moves to the next iteration.
break stops a loop immediately. continue skips the current iteration and moves to the next iteration.
Level
🟡 Control Flow and Core Programming
🟡 Control Flow and Core Programming
Example File
break-continue.cppMain Focus
Concept + syntax + practical C++ program
Concept + syntax + practical C++ program
Why should you learn this?
- It helps you write correct and readable C++ programs.
- It is used repeatedly in school practicals, projects and competitive programming.
- It builds the base for advanced topics such as OOP, STL and data structures.
Important Terms
| Term | Meaning / Use |
|---|---|
| break | Break used in break and continue Statements programming. |
| continue | Continue used in break and continue Statements programming. |
| loop control | Loop control used in break and continue Statements programming. |
| skip | Skip used in break and continue Statements programming. |
| terminate | Terminate used in break and continue Statements programming. |
Syntax / Pattern
break; and continue;
Example Program
#include <iostream>
using namespace std;
int main(){
for(int i=1; i<=5; i++){
if(i == 3) continue;
cout << i << " ";
}
return 0;
}
Expected Output
1 2 4 5
Program Explanation
- When i is 3, continue skips printing.
- Loop continues with i = 4.
Exam Tip: In C++ practical answers, write the logic first, then the program, then expected output. For theory, always include one suitable example.
Where will you use it?
- search operations
- input validation
- filtering values
Common Mistakes
- Using break where continue is needed.
- Creating unreachable code after break.
Practice Tasks
- Stop loop when number is 0.
- Print numbers 1-10 except multiples of 3.
Summary
break and continue Statements is an important C++ topic. Learn the definition, understand the syntax, run the example program and then solve the practice tasks to make the concept strong.
What is break and continue Statements?
break and continue Statements
break stops a loop immediately. continue skips the current iteration and moves to the next iteration.
break stops a loop immediately. continue skips the current iteration and moves to the next iteration.
Level
🟡 Control Flow and Core Programming
🟡 Control Flow and Core Programming
Example File
break-continue.cppMain Focus
Concept + syntax + practical C++ program
Concept + syntax + practical C++ program
Why should you learn this?
- It helps you write correct and readable C++ programs.
- It is used repeatedly in school practicals, projects and competitive programming.
- It builds the base for advanced topics such as OOP, STL and data structures.
Important Terms
| Term | Meaning / Use |
|---|---|
| break | Break used in break and continue Statements programming. |
| continue | Continue used in break and continue Statements programming. |
| loop control | Loop control used in break and continue Statements programming. |
| skip | Skip used in break and continue Statements programming. |
| terminate | Terminate used in break and continue Statements programming. |
Syntax / Pattern
break; and continue;
Example Program
#include <iostream>
using namespace std;
int main(){
for(int i=1; i<=5; i++){
if(i == 3) continue;
cout << i << " ";
}
return 0;
}
Expected Output
1 2 4 5
Program Explanation
- When i is 3, continue skips printing.
- Loop continues with i = 4.
Exam Tip: In C++ practical answers, write the logic first, then the program, then expected output. For theory, always include one suitable example.
Where will you use it?
- search operations
- input validation
- filtering values
Common Mistakes
- Using break where continue is needed.
- Creating unreachable code after break.
Practice Tasks
- Stop loop when number is 0.
- Print numbers 1-10 except multiples of 3.
Summary
break and continue Statements is an important C++ topic. Learn the definition, understand the syntax, run the example program and then solve the practice tasks to make the concept strong.