New course! Every coder should learn Generative AI!
Try a free lesson0
Does the 'break' statement terminate all types of loops?
In the tutorial, it is written that "The break statement's role is to terminate the switch statement." For example, for(int x=0; x<8; x++) { if (x==2){ x++; continue; } else if (5*x==20) break; else cout << 5*x; } When x=4, does the break statement above stop the entire 'for' loop? And does the break statement work for the 'while' loop and the 'do while' loop?
1 Answer
- 1
yes; the break statement will terminate all functional loops.