Is “else if” a single keyword?

后端 未结 8 1972
忘了有多久
忘了有多久 2021-01-31 01:13

I am new to C++. I often see conditional statement like below:

if 
  statement_0;
else if
  statement_1;

Question:

Syntacticall

8条回答
  •  遥遥无期
    2021-01-31 01:38

    An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.

    When using if , else if , else statements there are few points to keep in mind.

    An if can have zero or one else's and it must come after any else if's.

    An if can have zero to many else if's and they must come before the else.

    Once an else if succeeds, none of he remaining else if's or else's will be tested.

    have a look if...else statement tutorial.

提交回复
热议问题