You are on page 1of 3

Name: Auti Sai Sunil

Roll no: 04
Batch: C1
Practical no: 2

Q. Write a PHP program to print demonstrate the use of Decision making control
structures using-
a. If statement
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
$num=23;
if($num>0)
{
echo"Number is positive";
}
?>
</body>
</html>

Output:

b. If-else statement
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
$num=27;
if($num%2==0)
{
echo"$num is even";
}
else
{
echo"$num is odd";

}
?>
</body>
</html>

Output:

c. Switch statement
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
$month=2;
switch($month)
{
case 1: echo"January";
break;
case 2:echo"February";
break;
case 3:echo"March";
break;
case 4:echo"April";
break;
case 5:echo"May";
break;
case 6:echo"June";
break;
case 7:echo"July";
break;
case 8:echo"August";
break;
case 9:echo"September";
break;
case 10:echo"October";
break;
case 11:echo"November";
break;
case 12:echo"December";
break;
default:echo"You entered invalid month";
break;
}
?>
</body>
</html>

Output:

You might also like