Break Statement in C language:
(1) The break statement enables a program to skip over part of the code. A break statement terminates the smallest enclosing while, do-while, for or switch statement. Execution resumes at the statement immediately following the body of the terminated statement.
(2) Sample C language code and its output, as shown:
#include <stdio.h> #include <conio.h> //BREAK Statement int main() { int x; for (x = 0; x < 20; x++) { if (x == 15) { //exit from loop when x = 15 break; } printf(“%d\n”, x); } getch(); return 0; } |
(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.
(4) After building the code, press the “Run” button, as shown.
(5) After pressing the “run” button, the output screen is opened, as shown.