Arduino-if-else-statement

提供:Dev Guides
移動先:案内検索

Arduino-If…elseステートメント

*if* ステートメントの後に、オプションのelseステートメントを続けることができます。これは、式が偽の場合に実行されます。

if…elseステートメントの構文

if (expression) {
   Block of statements;
}
else {
   Block of statements;
}

if…elseステートメント–実行シーケンス

If Else Statement

/*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;
   }
}