if, else if, else

Tests if a condition is TRUE or FALSE.


If the test condition equates to boolean TRUE, the code block following the condition parentheses is executed.



if(test condition) {

//do this code if TRUE


//otherwise condition is FALSE, so continue


Optional else if conditions can follow, as well as optional else statements:


Compile & Run:

Please enter your favourite number:
66 is less than 100!

Leave a Reply