 break statement Causes the enclosing for, range-for, while or do-while loop or  switch statement to terminate.
Used when it is otherwise awkward to terminate the loop using the condition expression and conditional statements.
 Syntax    attr(optional) break ;     

  Explanation After this statement the control is transferred to the statement immediately following the enclosing loop or switch. As with any block exit, all automatic storage objects declared in enclosing compound statement or in the condition of a loop/switch are destroyed, in reverse order of construction, before the execution of the first line following the enclosing loop.
 Keywords break.
 Notes A break statement cannot be used to break out of multiple nested loops. The goto statement may be used for this purpose.
 Example  #include <iostream>
 
int main()
{
    int i = 2;
    switch (i) {
        case 1: st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << "1";   //<---- maybe warning: fall through
        case 2: st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << "2";   //execution starts at this case label (+warning)
        case 3: st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << "3";   //<---- maybe warning: fall through
        case 4:                     //<---- maybe warning: fall through
        case 5: st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << "45";  //
                break;              //execution of subsequent statements is terminated
        case 6: st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << "6";
    }
 
    st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << '\n';
 
    for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 5; k++) {    //only this loop is affected by break
            if (k == 2) break;           //
            st8b7c:f320:99b9:690f:4595:cd17:293a:c069cout << j << k << ' ';  //
        }
    }
} Possible output:
2345
00 01 10 11   See also    [[fallthrough]](C++17)   indicates that the fall through from the previous case label is intentional and should not be diagnosed by a compiler that warns on fall-through 
   C documentation for break 
  

    
{'path': 'public/docs/cpp/language/break.html', 'source': 'DevDocs.IO'}