Professional Documents
Culture Documents
Loops Final
Loops Final
Loops Final
WHAT IS A LOOP?
• Loops are used to repeat a block of code
until the specified condition is met.
OR
• A series of instructions that is repeated until
a terminating condition is reached.
Flowchart
TYPES OF LOOPS
There are four types of loops
• FOR LOOP
• WHILE LOOP
• DO WHILE LOOP
• NESTED LOOP
For loop
• Executes a sequence of statements multiple
times.
• Abbreviates the code that manages the loop
variable.
SYNTAX:
For(initialization ; test condition;++/--)
Flow chart
of for loop
WHILE LOOP
• Repeats a group of statements while a given condition is true.
SYNTAX:
while(test condition)
loop body;
}
FLOWCHART
OF A WHILE
LOOP
DO WHILE LOOP
• Just like a while loop.
SYNTAX:
Do
loop body;
while(condition);
Flowchart
Nested loop
• One loop within another loop.
• The concept of inner and outer loop is used.
• SYNTAX:
outer loop
{
inner loop
}
Flowchart