Controls the order in which each calculation operation executes.
3.1 Statement and program block{} is a statement terminator, {} is a compound statement (that is, the program block, can always declare a variable), syntactically equivalent to a single statement, 3.2 3.3 if-else statement If-else:else optional, nested automatic inner layer matching, it is recommended to add {} to clarify or change the matching relationship; If-else If-else: Multi-path determination, only one execution; 3.4 switch statement switch (expression) {Case constant expression: statement ...Default: Statement} Multi-path determination, unless a break or return is encountered, each branch is tested for execution; 3.5 while with For loop while (expression)Statementfor (expression 1, expression 2; expression 3)StatementWhen continue is not included, it is equivalent to: expression 1;while (expression 2) {Statementexpression 3;The break and return can terminate the loop, the comma operator has the lowest priority, evaluates from left to right, and sometimes it can be used to turn several consecutive statements into a statement, which is good for a single expression multi-step calculation of the macro, or closely related structures such as element Exchange: Temp=s[i], s[i]=s[j], s[j ]=temp;3.6 Do-while Loop doStatementwhile () 3.7 The break with the continue statement continue used for looping. On while or do-while: perform the test immediately; for: control transfers to the increment loop variable part; Break is used to jump out of the loop and switch;3.8 Goto statement and label Goto label; Label:StatementGoto is theoretically unnecessary, sometimes difficult to understand, as little as possible, can be used to jump out of multiple loops, the label name of the same variable, can be located in the corresponding Goto function before any statement, scope of the entire function;
C Programming Language (2nd edition • New version) Chapter 3rd control Flow