#10. Choose the right loop structure
C++ has three loop instructions: for , while and do ... while . To choose wisely among them, you need to know what their differences are. 1) for A for loop makes sense when you repeat an action for a known number of times, or for all the elements of a known set. This is the syntax of a for loop: for (initialization ; condition; expression) { statement } statement is actually a compound statement, that is, a block of code. This is called the body of the loop. In contrast, the initialization, condition and expression together are called the header of the loop. The initialization is a single statement which ends at the semicolon I wrote after it. The condition is a boolean expression. The expression is a statement. It should be a single statement which modifies one variable which is involved in the condition (see #guideline #5 ). The initialization is performed. Then, the condition is evaluated. Then, two things can happen. I...