1.What can we do with the while statement?
We can evaluate expressions and when it evaluates to true the statement gets executed
2. What value needs the statement in the brackets evaluate to in order for the loop to continue?
true
3. What is an infinite loop?
That is a loop in which the expression always evaluates to true, the while loop will execute forever.
4. What is an iteration?
Each time a loop executes, it is called an iteration .
1.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 (also called a for loop ) is ideal when we know exactly how many times we need to iterate
2. How would you write a for-loop in code?
for (int count{ 0 }; count < 10; ++count)
std::cout << count << ' ';
3. What is an off-by-one error?
Off-by-one errors occur when the loop iterates one too many or one too few times. This generally happens because the wrong relational operator is used in the conditional-expression (eg. > instead of >=). These errors can be hard to track down because the compiler will not complain about them â the program will run fine, but it will produce the wrong result.