Process control,
Sequence Control:
Allows the program to run in sequence. If no other control statements are encountered, the program runs from left to right and from top to bottom by default.
Branch Control:
There are three branch control options for execution of the program:
① Single branch if statement
If (conditional expression) {statement ;}
② Dual-branch if-else statement
If (condition expression) {statement;} else {statement ;}
③ Multi-branch if-else if statement
A conditional expression can also be a function. Its final return value is a Boolean value.
After else finds an entry (an expression that meets the condition), the execution will not continue even if other entries meet the condition.
If (condition expression 1) {Statement 1;} else if (condition expression 2) {Statement 2;} else if (condition expression 3) {Statement 3 ;} else {Statement 4 ;}
③ Multi-branch switch-case statement
When the compiler made a mistake in the switch statement, the case flag would only match once, and the matching case would be executed in a dark place. This is a historical issue.
Break indicates that subsequent operations are interrupted and the switch statement exists.
The data type of the conditional expression must be consistent with the constant type of case.
Switch (condition expression) {case constant 1: Statement 1; break; case constant 2: Statement 2; break; case constant n: Statement n; break; default: Statement ;}
Loop Control:
I. for loop operation process
Ⅱ while loop: Judge before execution
Iii. do while LOOP execution before judgment