comparison of the IF statement and the switch statement1. If statement:often used in small branches of the occasion;can be used to determine whether a value is within a range; 2. Switch statement:often used for more branches of the occasion;constants that require their corresponding branches must be strictly equal to a certain value;
3, Summary: if the range of values is large, it is clear that the IF statement is superior to the switch statement. When the value of an expression is a real number, only the IF statement is usually used.
comparison of the while statement and the Do...while statement1. While statement (as type):first judge, after the execution of the loop body;loops may not be executed at once;there is no semicolon after the while condition expression;
2. Do...while statement (until type):first the loop body is executed, then the value of the conditional expression is judged;Be executed at least once under any conditions;The while conditional expression is followed by a semicolon;
3, Summary: the while statement and do ... While statements are commonly used looping statements, but the order of execution and the number of executions are different.
the difference between a break statement and a continue statement1. Break statement:It can be used not only in the circulation body, but also in the swith .... case;interrupt the loop and jump to the level of the loop outside the body;
2. Continue statement:can only be used in the circulation body;interrupt the loop and jump to the outer body of the cycle;
3, Summary: both the break statement and the continue statement have an interruption, but their respective scopes of use and scope vary.
C + + 's "Control structure"