0% found this document useful (0 votes)
74 views3 pages

Practical No 3 (WBP) 04

The document describes a student named Auti Sai Sunil's practical assignment on using different looping structures in PHP, including a program using a while loop to output odd numbers from 1 to 50, a do-while loop to output the multiplication table of the number 2, a for loop to output even numbers from 1 to 50, and a foreach loop to output the colors in an array.

Uploaded by

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

Practical No 3 (WBP) 04

The document describes a student named Auti Sai Sunil's practical assignment on using different looping structures in PHP, including a program using a while loop to output odd numbers from 1 to 50, a do-while loop to output the multiplication table of the number 2, a for loop to output even numbers from 1 to 50, and a foreach loop to output the colors in an array.

Uploaded by

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

Name: Auti Sai Sunil

Roll no: 04
Batch: C1
Practical no: 3

Q. Write a PHP program to demonstrate the use of Looping structures using-


a) While statement
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
$i=1;
while($i<=50)
{
echo"$i<br>";
$i=$i+2;
}
?>
</body>
</html>

Output:

b) Do-while statement
<html>
<head>
<title>hello</title>
</head>
<body>
<?php
$num=2;
$i=1;
echo"Table of $num is: <br>";
do
{
$table=$num*$i;
echo"$table<br>";
$i++;
}while($i<=10);

?>
</body>
</html>

Output:

c) For statement
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
echo"Even numbers from 1 to 50: <br>";
for($i=1;$i<=50;$i++)
{
if($i%2==0)
{
echo"$i<br>";
}
}
?>
</body>
</html>

Output:

d) Foreach statement
<html>
<head>
<title>Hello</title>
</head>
<body>
<?php
$x=array("Blue","Red","Yellow","Green","Pink");
foreach($x as $y)
{
echo"$y<br>";
}
?>
</body>
</html>
Output:

You might also like