LO0PS
IN
C-PROGRAMMING
By
Dhurgham Fahem
Hani Ali
Outline
 What is the loop
 For Loop
 While Loop
 Do…while Loop
What is the loop
Hello World
printf("*********** Hello World *************");
printf("*********** Hello World *************");
printf("*********** Hello World *************");
printf("*********** Hello World *************");
.
.
.
printf("*********** Hello World *************");1
2
Flowchart loop
Start
StatementCondition
True
End
False
3
for ( init; condition; counter)
{
statement(s);
}
for Loop
for ( int x=0; x<=5; x=x+1)
{
printf("******* Hello World *******");
}
4
5
Start
Code block
x<=5
End
x=x+1
Flowchart (for) loop
True
False
6
Start
End
Sequence
Flowchart (for) Nested loop
TrueFalse
True
False
Condition 1
Condition 2
End
7
while Loop
while(condition)
{
statement(s);
}
int a = 10;
while( a < 20 )
{
printf("value of a: %dn", a);
a++;}
8
9
Flowchart (While) loop
Start
a++
a < 20
End
True
False
10
Flowchart Nested loop
Statement
True
False
End loop
Condition
True
False
End loop
Inner loop
Outer loop
Start
Condition
11
do…while Loop
do
{
statement(s);
}while( condition );
do
{
printf("value of a: %dn", a);
a = a + 1;
}while( a < 20 );
12
13
Flowchart (do…while )loop
Start
value of a
a < 20
End
True
False
14
Flowchart do while Nested loop
Start
Statement
Condition
TrueFalse
End loop
Condition
TrueFalse
End loop
Inner loopOuter loop
15
References
www.tutorialspoint.com
https://www.facebook.com/tutorialspointindia
https://twitter.com/tutorialspointindia
Loop

Loop