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

PHP else if ladder Statements ?


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 output of the program using else if ladder statement.
 <html>
 <body>
 <?php
 $marks=75;
 if($marks>=90)
 echo“ O”;
 else if($marks>=80&&$marks<89)
 echo(“A”);
 else if($marks>=70&&$marks<80)
 echo “B”;
 else if($marks>=60&&$marks<70)
 echo “C”;
 else if($marks>=50&&$marks<60)
 echo “D”;
 else if($marks>=40&&$marks<50)
 echo “E”;
 else
 echo “F”;
 }
 ?>
 </body>
 </html>
Output
B