Javatpoint Logo
Javatpoint Logo

Else-if Statement

This type of statement is also known as 'Else-if' ladder. It is useful when you want to check more than one condition within a code.

If the condition of any 'If' block is True, then the statements associated with that block are executed. If none of the conditions are True, then the statements inside default else block are executed.

Syntax of Else-if Statement

Flowchart of Else-If Statement

PowerShell Else-if Statement

Examples

The following examples describe how to use the Else-If statement in PowerShell:

Example 1: In this example, we check a number is positive, negative, or zero.

Output:

Number is zero

Example 2: In this example, we find the grade of the student according to its percentage.

Output:

Grade B

Example 3: In this example, we check the greatest number among the three variables.

Output:

The value of Variable 'c' is greater than the value of variable 'a' and 'b'.

Next TopicSwitch Statement




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA