🟡 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.
Level
🟡 Control Flow and Core Programming
Example File
break-continue.cpp
Main Focus
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

TermMeaning / Use
breakBreak used in break and continue Statements programming.
continueContinue used in break and continue Statements programming.
loop controlLoop control used in break and continue Statements programming.
skipSkip used in break and continue Statements programming.
terminateTerminate 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

  1. Stop loop when number is 0.
  2. 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.
Level
🟡 Control Flow and Core Programming
Example File
break-continue.cpp
Main Focus
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

TermMeaning / Use
breakBreak used in break and continue Statements programming.
continueContinue used in break and continue Statements programming.
loop controlLoop control used in break and continue Statements programming.
skipSkip used in break and continue Statements programming.
terminateTerminate 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

  1. Stop loop when number is 0.
  2. 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.

← Back to C++ Tutorial