Break Statement
Break Statement
By using this jumping statement, we can terminate the further execution of the program and transfer the control to the end of any immediate loop or switch body.
To do all this we have to specify a break jumping statements whenever we want to terminate from the loop.
Syntax:
break;
NOTE: This jumping statements always used with the control structure like switch case, while, do while, for loop etc.
NOTE: As break jumping statements ends/terminate loop of one level . so it is referred to use return or goto jumping statements , during more deeply nested loops.
Qus. 1 : What is the role of the break statement in a loop?
- It exits the current loop and continues with the next iteration
- It terminates the current loop and transfers control to the next statement after the loop
- It skips the current iteration and moves to the next iteration
- It repeats the current iteration
- break stops the loop, continue skips the rest of the iteration
- Both stop the loop
- break skips to the next iteration, continue exits the loop
- Both skip to the next iteration
- It breaks out of both loops.
- It only breaks out of the innermost loop.
- It causes a compile-time error.
- It stops the program.
Programs
c program to input any number and print its table using goto statement
C program to input any number and print its factorial value using goto statement
Write a program entered number check the number is even or odd by using goto statement.