English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Explain the if elseif else statement. With suitable example.

Advertisements
Advertisements

Question

Explain the if elseif else statement. With suitable example.

Answer in Brief
Advertisements

Solution

  1. If-elseif-else statement is a combination of if-else statement.
  2. More than one statement can execute the condition based on user needs.

Syntax:

if (1st condition)
{
Execute statement(s) if condition is true;
}
elseif(2nd condition)
{
Execute statement(s) if 2ndcondition is true;
}
else
{
Execute statement(s) if both conditions are false;
}

Example Program:

<?php
$Pass_Mark=35;
$first_class=60;
$Student_Mark=70;
if ($Student_Mark>= $first_class){ echo “The Student is eligible for the promotion with First Class”;
}
elseif ($Student_Mark>= $Pass_Mark){ echo “The Student is eligible for the promotion”;
}
else {
echo “The Student is not eligible for the promotion”;
}?>
shaalaa.com
  Is there an error in this question or solution?
Chapter 6: PHP Conditional Statements - Evaluation - PART – IV [Page 111]

APPEARS IN

Samacheer Kalvi Computer Applications [English] Class 12 TN Board
Chapter 6 PHP Conditional Statements
Evaluation - PART – IV | Q 4. | Page 111
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×