Description of the select statement

  • 可以根据条件控制程序流程,改变程序执行的顺序
  • 选择语句可以嵌套使用
  • 当条件满足时就会执行相应的语句

Flow control statements Category:
sequential structure
Select structure: if statements, switch statements
cyclic structure: while statements, for statements

 

Select statement is probably the most common flow control statements, allowing you to perform more than one statement in accordance with the value of the expression.

1, if the statement

The if statement is the most basic select statement, a statement that choose to perform according to the results of a Boolean expression.

2, switch statements

The switch statement can be considered cascaded if statement is the result of natural evolution, functionally similar to the cascading if statement, but more concise and more flexible. Equal to the switch statement is executed and expression statement label specified list of values.

Guess you like

Origin blog.csdn.net/weixin_44018338/article/details/91458443
Recommended