C++ break is utilized to break a circle or switch articulation. It intrudes on the current execution stream of the program under given circumstances. On account of an internal circle, it just breaks the inward circle. bounce articulation; break;

example

result

The break in C or C++ is a circle control proclamation which is utilized to end the circle. When the break explanation is experienced from inside a circle, the circle emphasess stops there and control gets back from the circle quickly to the primary assertion after the circle. Sentence structure: break; Fundamentally break explanations are utilized in the circumstances when we are don't know about the real number of emphasess for the circle or we need to end the circle in view of some condition.

break with while loop


// program to find the sum of positive numbers// // if the user enters a negative numbers, break ends the loop// // the negative number entered is not added to sum// int main() { int number; int add = 0; while (true) { // take input from the user// cout << "Enter a number from user: "; cin >> number; // break condition// if (number < 0) { break; } // add all positive numbers// add+= number; } // display the sum// cout << "The add is " << add << endl; return 0; }

result


Enter a number: 1 Enter a number: 2 Enter a number: 3 Enter a number: -5 The add is 6.
In the above program, the client enters a number. The while circle is utilized to print the all out amount of numbers entered by the client. Here, notice the code.
if(number < 0) { break; }