Before discussing various loops in
'C', it is necessary to understand about loop, what exactly it is. We
use loop when we have to repeat a block of code. For many times, it is
required to execute the same code a number of times for some cases. Then
we take the help of loop.
There are three types of loop:-
1. while
2. dowhile
3. for
There are two keywords which are important in loop. So,
before studying loops in deep, lets see these two keywords. They are:-
1. break
2. continue
1. Break
We use break to terminate the loop. In other words, we can
say that it is useful to get exit from a loop under some circumstances.
This will be more clear in using loops in next chapters.
2. Continue
Continue is a keyword that controls the flow of loops.
Sippose we are executing a loop and hit a continue statement, the loop
will stop its current iteration, update itself (in case of for loops)
and begin to execute again from the top.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment