Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
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

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA