Javatpoint Logo
Javatpoint Logo

R else if statement

This statement is also known as nested if-else statement. The if statement is followed by an optional else if..... else statement. This statement is used to test various condition in a single if......else if statement. There are some key points which are necessary to keep in mind when we are using the if.....else if.....else statement. These points are as follows:

  1. if statement can have either zero or one else statement and it must come after any else if's statement.
  2. if statement can have many else if's statement and they come before the else statement.
  3. Once an else if statement succeeds, none of the remaining else if's or else's will be tested.

The basic syntax of If-else statement is as follows:

Flow Chart

R else if statement

Example 1

Output:

R else if statement

Example 2

Output:

R else if statement

Example 3

Output:

R else if statement

Example 4

Output:

R else if statement

Example 5

Output:

R else if statement
Next TopicR Switch Statement




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA