The if else if statement is an extension of the “if else” conditional branching statement. When the expression in the “if’ condition is “false” another “if else” construct is used to execute a set statements based on expression.
syntax :
If(expression)
{ statements }
else if (expression)
{statements}
else if (expression)
{statements}
Example:
#include <iostream.h>
void main()
{
int per;
cout <<"Enter your percentage::";
cin >> per;
If (per>=80)
cout <<"passed with Distinction"<<end1;
else if (per>=60)
cout <<"passed with Distinction"<<end1;
else if (per>= 50)
cout <<"second class"<<end1;
else
cout<<"Third class"<<end1;
}
Result:
Enter your Percentage : : 60
First Class