Arduino-if-statement

提供:Dev Guides
2020年6月23日 (火) 04:16時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

Arduino-Ifステートメント

括弧で囲まれた式と、ステートメントまたはステートメントのブロックを取ります。 式が真の場合、ステートメントまたはステートメントのブロックが実行されます。それ以外の場合、これらのステートメントはスキップされます。

ifステートメントのさまざまな形式

  • フォーム1 *
if (expression)
   statement;

ステートメントが1つある場合は、中括弧\ {}なしでifステートメントを使用できます。

  • フォーム2 *
if (expression) {
   Block of statements;
}

ifステートメント-実行シーケンス

IFステートメント

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