目录

If statement

它在括号和语句或语句块中使用表达式。 如果表达式为true,则执行语句或语句块,否则将跳过这些语句。

不同形式的if语句

Form 1

if (expression)
   statement;

如果您有一个语句,则可以使用不带大括号{}的if语句。

Form 2

if (expression) {
   Block of statements;
}

if语句 - 执行顺序

IF声明

例子 (Example)

/* 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++;
   /* check the boolean condition */
   If ( ( A < B ) && ( B != 0 )) /* if condition is true then execute the following statement*/ { 
      A += B;
      B--;
   }
}
↑回到顶部↑
WIKI教程 @2018