Sometimes multiple conditions must be determined to determine what operations to perform. In this case, if... Else if... Else statement. The statement syntax is as follows:
If (expression 1)
{Statement Block 1} // code that meets the expression execution
Else if (expression 2)
{Statement Block 2} // code that meets the expression execution
Else if (expression 3)
{Statement block 3} // code that meets the expression execution
......
Else
{Statement block n} // code that complies with the expression execution
The execution process is described as follows.
(1) first judge expression 1. if its value is true, execute <statement Block 1> and end the if statement.
(2) if expression 1 is set to false, expression 2 is judged. if expression 1 is set to true, <statement Block 2> is executed and the if statement is ended.
(3) If expression 2 is set to false, continue to judge the values of other expressions.
(4) If the values of all expressions are false, execute <statement Block n>.