An else if ladder is a special case of nested if statement where nesting take place only in the else part when an action has to be selected based on range of value then this statement is used .
Q.) W.A.P to print the greater number using simple if-else statement.
#include<stdio.h>
#include<conio.h>
void main()
{
int marks;
printf(“enter the marks\n”);
scanf(“%d”,&marks);
if(marks>=90)
printf(“ O”);
else if(marks>=80&&marks<89)
printf(“A”);
else if(marks>=70&&marks<8`0)
printf(“B”);
else if(marks>=60&&marks<70)
printf(“C”);
else if(marks>=50&&marks<60)
printf(“D”);
else if(marks>=40&&marks<50)
printf(“E”);
else
printf(“F”);
getch();
}
Output
enter the marks: 85
A