codeGK
Code it ALL
C++ Break - CodeGK
♦ C++ Break

♣ About C++ Break

The break statement ceases an ongoing loop such as for, while and do-while.
Control block switches to next code block after the ceasing.

♣ C++ Break Syntax

Below is the representation of C++ Break Syntax.
Basic Syntax
break;
Syntax Explanation:
break : keyword in C++ for terminating a Loop

♣ Example1: Break out of For Loop in C++

In this example, control is switched out of a For Loop.
To be specific if the loop encounters value 6, it breaks.
Example
Input:
Output:

♣ Example2: Break out of While Loop in C++

In this example, control is switched out of a While Loop after 2 seconds.
Example
Input:
Output:
Prev_LessonNext_Lesson