Iterations Flashcards

1
Q

What are the three loop types

A

For , while, Do.. while

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is the while loop used

A

while(condition)
{
statement
}
where the varibale inside the loop must be changed otherwise it will loop forever

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When do we use the while loop

A

The condition is met before the loop
-when the number of iterations is unknown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When is the for loop used

A

-The for loop always has an iteration variable that is de/incremented.
-The number of loops is known
-when the user wants to use the iterator variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is the for loop strcutured

A

for ( [exp1 = initilisation]; [exp2 = controlling expression]; [exp3 = adjustment])
{
statement
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does the do while loop work

A

The decision is made at the bottom of the loop so the loop runs at least once.
The loop is ended when the condition is false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly