If Else

The if statement may have an optional else block. The syntax of the if..else statement is:

*Syntax:
if (test expression) {
    // run code if test expression is true
}
else {
    // run code if test expression is false
}

How if...else statement works?
*If the test expression is evaluated to true,

statements inside the body of if are executed.
*statements inside the body of else are skipped from execution.
*If the test expression is evaluated to false,

*statements inside the body of else are executed
*statements inside the body of if are skipped from execution.
Posted on by