While loop benefits
While loop format
int ctr=1;
while (ctr
{
System out print (ctr);
ctr++;
}Do-while benefits
Do-while format
int ctr=1;
do
{
System.out.println(ctr);
ctr++;
}
while (ctrFor loop
Repeated a specific #of times
Allows u to input # of repetitions
For loop format
int ctr=1;
for(ctr=1; ctr
Each pass through a loop is called an
Iteration
In a group of nested loops, which loop is executed the least #of times?
Outer
Nested loops
Outer loop changes after inner loop is completely finished
for (rows=0;rows
AAAA AAAA AAAA AAAA AAAA
Nested for loop with output:
N
NN
The inner would be
for (col=0; col
What’s wrong? int x=4; while(x>1) x++;
The loop is an infinite
Fix: int x=1; while(x