Conditional Statement (Mistake 2)
Refer to the following codes:
- <?php
- $mark = 60;
- if ($mark < 50){
- $grade = "D";
- }
- else if ($mark < 70){
- $grade = "C";
- }
- if ($mark < 80){
- $grade = "B";
- }
- if ($mark < 100){
- $grade = "A";
- }
- echo "The grade for $mark is $grade";
- ?>
The codes should output "The grade for 60 is C". However the codes' output is "The grade for 60 is A". Be the first to put your comments what is wrong with the codes.
கடைசியாக மாற்றப்பட்டது: Saturday, 23 February 2019, 10:11 AM