if, else if, else

We can execute statements depends on condition using if, else if or else keyword.
Syntax:

Here the first condition inside if will be checked. If this condition is true then statements inside if will be executed and else ifelse will be skipped otherwise condition inside else if() will be checked and if this condition is true then statements inside else if will be executed and else will be skipped otherwise statements inside else will be executed.
Any non-zero value will be treated as true and zero is treated as false. i.e:

here 10>8 is true that means condition inside if is true. In the same manner for

or

condition inside if is true.

Example:

OUTPUT

Enter a number : 102
Your entered positive number is greater than 100


Next Previous