Professional Documents
Culture Documents
C Presentation
C Presentation
Looping statement in c
Presented by:
Roshan kr thakur
Sushmita shah
Muskan upadhyay
Content
Objective
Introduction of loop
Types of loop
LOOPING IN C
Loop
loop is used to execute the block of code several times
according to the condition.
A loop has four statement that have different purpose:-
1. Initialization
2. Test expression
3. Update expression
4. The body of the loop
LOOPING IN C
Flow chart
LOOPING IN C
Loops In C
Entry control loop
for loop
while loop
Exit control loop
do while loop
LOOPING IN C
for loop
• It is entry controlled loop found in C
requires 3 parts:
1) Initialization
2) Condition
3) Increment
LOOPING IN C
Flow char
LOOPING IN C
For loop
Syntax Example
#include<stdio.h>
for ( variable
Void main()
initialization; condition; {
variable update ) Int =0;
{ For(i=1; i<10;i++)
Code to execute while Printf(“%d\n”,i);
the condition is true Return0;
} }
LOOPING IN C
While loop
LOOPING IN C
Flowchart
LOOPING IN C
While loop
Syntax Example
while (expression) #include<stdio.h>
{ Int main()
// execute statements {
} Int i=1;
While(i<=5)
Printf(“%d\n”,i);
++i;
Return 0;
}
LOOPING IN C
Do while loop
• which test the loop condition at the top of the
loop, the do...while loop in C programming
language checks its condition at the bottom of
the loop.
• A do...while loop is similar to a while loop,
except that a do...while loop is guaranteed to
execute at least one time
LOOPING IN C
do While loop
Syntax Example
#include<stdio.h>
do
Int main ()
{ {
statement(s); int a = 1;
} Do
while( condition ); {
printf("value of a: %d\n",a); a = a +
1;
}
while( a <= 10 );
Return 0;
}
LOOPING IN C
Flow chart
LOOPING IN C
THE END