0% found this document useful (0 votes)
5 views4 pages

PR 2

The document contains PHP programs demonstrating the use of conditional statements including 'if', 'if-else', 'if-else if', and 'switch'. Each section provides examples that check conditions such as number comparisons, character checks, and day of the week evaluations. The code snippets illustrate how to implement these control structures in PHP.

Uploaded by

Geeta Birle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

PR 2

The document contains PHP programs demonstrating the use of conditional statements including 'if', 'if-else', 'if-else if', and 'switch'. Each section provides examples that check conditions such as number comparisons, character checks, and day of the week evaluations. The code snippets illustrate how to implement these control structures in PHP.

Uploaded by

Geeta Birle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

QUE 1.

Write a php program to use if statement


1. <?php
$num=67;
if($num<100)
{
echo "number is less than 100";
}
?>

2. <?php
$ch='a';
if($ch=='a')
{
echo "character is a";
}

?>
QUE 2. Write a php program to use if else statement
1. <?php
$num=46;
if($num%2==0)
{
echo "number is even";
}
else
{
echo "number is odd";
}
?>

2. <?php
$num=46;
if($num>0)
{
echo "number is positive";
}
else
{
echo "number is negative";
}
?>

QUE 3. Write a php program to use if else if statement


1. <?php
$a=50;
$b=40;
$c=45;
if($a>$b&&$a>$c)
{
echo "a is greater number";
}
elseif($b>$c)
{
echo "b is greater number";
}
else
{
echo "c is greater number";
}
?>

2. <?php
$day="wednesday";
if($day=="monday")
{
echo "day is monday";
}
elseif($day=="tuesday")
{
echo "day is tuesday";
}
elseif($day=="wednesday")
{
echo "day is wednesday";
}
elseif($day=="thusday")
{
echo "day is thusday";
}
elseif($day=="friday")
{
echo "day is friday";
}
elseif($day=="saturday")
{
echo "day is saturday";
}
elseif($day=="sunday")
{
echo "day is sunday";
}
?>

QUE 3. Write a php program to use switch statement


1. <?php
$month="june";
switch($month)
{
case "january":echo "month is january";
break;
case "feb":echo "month is feb";
break;
case "march":echo "month is march";
break;
case "april":echo "month is april";
break;
case "may":echo "month is may";
break;
case "june":echo "month is june";
break;
default:echo "month is not valid";
}
?>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy