Find grade of a student using elseif ladder
Notes:
PHP elseif ladder statement:
- helps us to check multiple conditional expressions
Displaying grades using elseif ladder statement:
$marks = 30;
if(($marks>=0) && ($marks<=30))
{
echo "Fail" ;
}
elseif(($marks>30) && ($marks<=50))
{
echo "C grade" ;
}
elseif(($marks>50) && ($marks<=70))
{
echo "B grade" ;
}
elseif(($marks>70) && ($marks<=90))
{
echo "A grade" ;
}
elseif(($marks>90) && ($marks<=100))
{
echo "A+ grade" ;
}
else
{
echo "invalid marks" ;
}
OR
$marks = 30;
if(($marks>=0) && ($marks<=30)):
echo "Fail" ;
elseif(($marks>30) && ($marks<=50)):
echo "C grade" ;
elseif(($marks>50) && ($marks<=70)):
echo "B grade" ;
elseif(($marks>70) && ($marks<=90)):
echo "A grade" ;
elseif(($marks>90) && ($marks<=100)):
echo "A+ grade" ;
else:
echo "invalid marks" ;
endif;
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a