[go: up one dir, main page]

0% found this document useful (0 votes)
79 views9 pages

Loops

Loops allow code to repeat until a condition is met. There are four main types of loops: while loops repeat while a condition is true, for loops repeat a specified number of times using a control variable that is initialized, tested, and updated each iteration. Do...while loops are similar to while loops but check the condition at the end of each iteration. Nested loops contain a loop within another loop to process multidimensional data, with the inner loop completing each iteration before moving to the next iteration of the outer loop.

Uploaded by

api-409124267
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views9 pages

Loops

Loops allow code to repeat until a condition is met. There are four main types of loops: while loops repeat while a condition is true, for loops repeat a specified number of times using a control variable that is initialized, tested, and updated each iteration. Do...while loops are similar to while loops but check the condition at the end of each iteration. Nested loops contain a loop within another loop to process multidimensional data, with the inner loop completing each iteration before moving to the next iteration of the outer loop.

Uploaded by

api-409124267
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Loops

Jayleen Elifonzo and Skye Jimenez


Loops
● Functions that repeat until condition’s met.
○ While Loop
○ For Loop
○ Do...While Loop
○ Nested Loop
While Loops
- Represents statements
until condition is true.
For Loop
The for loop has 3 different Elements

● Controls variable
● Test control variable
● Update control variable
For Loops
A For Statement has the following syntax:

For ( initialization ; condition ; increment )

Statement;

}
For Loops
for(int count = 0; count < 5; count++)
System.out.println("Hello!");

● This will print “Hello!” 5 times.


Do… While Loops
- Like a while loop, but
- Tests the condition at the end.
Nested Loops
- A loop inside another loop.
- Useful when displaying
multidimensional data.
- 1st iteration of first loop will
initialize.
- 2nd loop finishes
Thank you!

You might also like