C Decision Making - Looping

The Break Statement



Sometimes while executing a loop it becomes desirable to skip a part of the loop or quit the loop as soon as certain condition occurs,. For example consider searching a particular number in a set of 100 numbers as soon as the search number is found it is desirable to terminate the loop.
C language permits a jump from one statement to another within a loop as well as to jump out of the loop. A break statement provides an early exit from for, while, do and switch constructs.
A break causes the innermost enclosing loop or switch to be exited immediately.

Continue statement

During loop operations it may be necessary to skip a part of the body of the loop under certain conditions. Like the break statement C supports similar statement called continue statement.
The continue statement causes the loop to be continued with the next iteration after skipping any statement in between. The continue with the next iteration the format of the continue statement is simply:
Continue; 
        


Make Comments..!!


Oops!! No posts from user.

Download Android App