W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
if 語句后面可以跟隨一個(gè)可選的 else if ... else 語句,其對(duì)于測(cè)試各種條件非常有用。
當(dāng)使用 if ... else if ... else 語句時(shí),請(qǐng)記住:
一個(gè) if 可以有0或一個(gè)else語句,它必須在所有else if之后。
if 可以有0到多個(gè)else if語句,它們必須在else之前。
一旦 else if 成功,將不會(huì)測(cè)試剩余的else if或else語句。
if (expression_1) { Block of statements; } else if(expression_2) { Block of statements; } . . . else { Block of statements; }
/* Global variable definition */ int A = 5 ; int B = 9 ; int c = 15; 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 */ else if ((A == B )||( B < c) ) /* if condition is true then execute the following statement*/ { C = B* A; }else c++; }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: