Loop structure:
One, while statement
While statement notation: while (expression) statement
Function: Executes the statement repeatedly (the loop body) until the expression is not established.
When the loop body is multiple statements, the compound statement ({...}) is used.
Second, for statement
For statement notation: for (expression 1; expression 2; expression 3) statement
Pay particular attention to the use of loop control variables, which are variables that determine the number of cycles executed:
Be sure to assign an initial value. (expression 1 for a For statement is called an assignment of an initial value expression, typically used to assign an initial value to a loop variable)
It is usually necessary to make a correction when the loop body is executed. (Expression 3 for the For statement is called a fixup expression, modifying the loop variable)
Third, break statement
The break statement is used within a loop statement or a switch statement.
The function is to jump out to the next statement.
Iv. Continue statements
The continue statement is used only in the loop body. The function is to end the loop, which is to skip the following statement that has not been executed in the loop body, and then proceed to the next execution of the loop (for the For statement, evaluate the expression 3).
C + + Fifth lesson loop structure