C++ else..if ladder

When we need to list multiple else if…else statement blocks. We can check the various conditions using the following syntax –

Syntax : C++ Else if ladder

if(boolean_expression 1){// When expression 1 is true}elseif( boolean_expression 2){// When expression 2 is true}elseif( boolean_expression 3){// When expression 3 is true}else{// When none of expression is true}

When the first Boolean condition becomes true then first block gets executed.

When first condition becomes false then second block is checked against the condition. If second condition becomes true then second block gets executed.