110
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:
- if statement can have either zero or one else statement and it must come after any else if’s statement.
- if statement can have many else if’s statement and they come before the else statement.
- 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
Example 1
Output:
Example 2
Output:
Example 3
Output:
Example 4
Output:
Example 5
Output:
Next TopicR Switch Statement