Looping
Looping
It is the
process of executing (running) block of statement more than one times until
some condition is made. Looping is a process of repeaed the activities unitl the operation is reached. Mainly we can categorized loop into two types:- on the
basic of control.
1.
Entry control loop
2.
Exit control loop
1 . Entry
control loop is checked at the beginning of loop or before executing block of
statement of loop. If the condition is false initially, the loop cannot be
executed even one times. (0 times).
Mainly there
are two types of entry control loop in c programming.
(1)
For () loop
(2)
While () loop
Example :-
Write a
program to display number from 1 to 100 by using for loop.
Int main()
{
Int I;
For ( i= 1;
i<=100; i++)
{
Printf(“%d/t”,i);
}
Return (0);
}
2 . Exit
control loop is checked at the end of the loop or end of the block of statement
of loop. If the condition is initially false, the loop will be executed at
once, do-while is the example of exit control loop.
Let us take
one example:-
Int main ()
{
I = 10;
do
{
Printf(“Cambridge
university”);
}
While (i<5);
The
Cambridge university is printed at once while.
No comments:
Post a Comment