Iterations Flashcards
What are the three loop types
For , while, Do.. while
How is the while loop used
while(condition)
{
statement
}
where the varibale inside the loop must be changed otherwise it will loop forever
When do we use the while loop
The condition is met before the loop
-when the number of iterations is unknown
When is the for loop used
-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 is the for loop strcutured
for ( [exp1 = initilisation]; [exp2 = controlling expression]; [exp3 = adjustment])
{
statement
}
How does the do while loop work
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