If Statement

Conditionals are logical operations involving comparison of quantities using the given conditional operators:

Condition Operators,

< Smaller than

<= smaller than or equal to

== Equal to

!= not equal to

>= greater than or equal to

> Greater than

Boolean operators -

&& And

|| Or

! Not

Syntax -

if (conditional1)

{

Block of statements executed if conditional 1 is true

}

else if (conditional2)

{

Block of statements executed if conditional 2 is true

}

else

{

Block of statements executed otherwise

}

Example –