What can we do with the while statement?
We can execute a piece of code repeatedly until some condition is met.
What value needs the statement in the brackets evaluate to in order for the loop to continue?
It needs to evaluate to true.
What is an infinite loop?
It is a loop that will execute forever, because the expression always evaluates to true.
What is an iteration?
Each time a loop executes is called iteration.
….
When is it a good idea to use a for statement (do a for loop) instead of the while loop we learned previously?
The for statement is preferred when we have an obvious loop variable because it lets us easily and concisely define, initialize, test, and change the value of loop variables.
How would you write a for-loop in code?
for (init-statement; condition; end-expression)
statement
What is an off-by-one error?
Off-by-one errors occur when the loop iterates one too many or one too few times to produce the desired result, eg. When we use > operator instead of >=.