Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

The break and continue statements

Sometimes during Programming, we need to go out of the Loop or skip the Loop when certain condition is valid. For those cases we use, Break or Continue Keywords .

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. The Break statement allows us to accomplish this task. 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;

Example Of Break

Check if the given number is prime no.

Using Continue, we are avoiding division by 0.


break and continue statements

Topics in C Programming

Copyright © 2009-2023 UrgentHomework.com, All right reserved.