> if Statement

An if statement consists of a boolean expression followed by one or more statements.

if (test expression/Condition)
{
      //statements to be executed if the condition is true
}

See Example

> if-else Statement

An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.

if (test expression/Condition)
{
      //statements to be executed if the condition is true
}
else
{
       //statements to be executed if the condition is false
}

See Example

> nested if Statement

You can use an if or else if statement inside another if or else if statement(s).

if (test expression/Condition)
{
      //statements to be executed if the condition is true
}
else
 if (test expression/Condition)
{
       //statements to be executed if the condition is true
}
else if (test expression/Condition)
{
       //statements to be executed if the condition is true
}
else
{
       //statements to be executed if the condition is false
}

See Example

switch Statement

switch statement allows a variable to be tested for equality against a list of values.

See Example