Practical lesson
Write a PHP function called getGrade($marks) that returns "A" for 80+, "B" for 60-79, "C" for 40-59, and "Fail" below 40. Call it with a few different values and echo the results, each on its own line.
Try it yourself
Write a PHP function called getGrade($marks) that returns "A" for 80+, "B" for 60-79, "C" for 40-59, and "Fail" below 40. Call it with a few different values and echo the results, each on its own line.
<?php
function getGrade($marks) {
// your logic here
}
echo getGrade(85) . "\n";
echo getGrade(65) . "\n";
echo getGrade(30) . "\n";
?>A B Fail