Loops Final

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

Loops IN java

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.

• The condition is tested before the execution of the code.

SYNTAX:

while(test condition)

loop body;

}
FLOWCHART
OF A WHILE
LOOP
DO WHILE LOOP
• Just like a while loop.

• The test condition is tested at the end of the loop body.

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

You might also like