/* */ Click to Join Live Class with Shankar sir Call 9798158723

else-if ladder statement in C ?


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 .



Syntax:-

if(condition)
stat f1
else if(con 2)
stat s1
else if(con 3)
stat s2
else if(con 4)
stat s4
………………..
………………….
else if(con n-1)
stat n-1
else
stat n


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