一个 if 语句后面可以有一个可选的else语句,当表达式为false时执行。
if ... else语句语法
- if (expression) {
- Block of statements;
- }
- else {
- Block of statements;
- }
if ... else语句 - 执行顺序

- /* Global variable definition */
- int A = 5 ;
- int B = 9 ;
- Void setup () {
- }
- Void loop () {
- /* check the boolean condition */
- if (A > B) /* if condition is true then execute the following statement*/ {
- A++;
- }else {
- B -= A;
- }
- }
转载本站内容时,请务必注明来自W3xue,违者必究。