0% found this document useful (0 votes)
40 views10 pages

Practical 1 AIM: To Find A Armstrong No Input

The document contains descriptions of 9 PHP programming practical exercises. The practicals include: 1) Checking if a number is Armstrong, 2) Calculating the sum of a series, 3) Finding the factorial of a number, 4) Finding the sum of natural numbers from 1 to 10, 5) Finding the sum of natural numbers divided by their factorials, 6) Returning the length of a string, 7) Finding the position of the first occurrence of a substring, 8) Reversing a string, and 9) Converting the first character of each word to uppercase. For each practical, the input code and expected output are provided.

Uploaded by

Nihal Tripathi
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)
40 views10 pages

Practical 1 AIM: To Find A Armstrong No Input

The document contains descriptions of 9 PHP programming practical exercises. The practicals include: 1) Checking if a number is Armstrong, 2) Calculating the sum of a series, 3) Finding the factorial of a number, 4) Finding the sum of natural numbers from 1 to 10, 5) Finding the sum of natural numbers divided by their factorials, 6) Returning the length of a string, 7) Finding the position of the first occurrence of a substring, 8) Reversing a string, and 9) Converting the first character of each word to uppercase. For each practical, the input code and expected output are provided.

Uploaded by

Nihal Tripathi
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/ 10

SARVAM FONIA ROLL.NO.

171279002

PRACTICAL 1

AIM: To find a Armstrong no

INPUT

<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
$num=8208;
$total=0;
$x=$num;
while($x!=0)
{
$rem=$x%10;
$total=$total+$rem*$rem*$rem*$rem;
$x=$x/10;
}
if($num==$total)
}
SARVAM FONIA ROLL.NO.171279002

{
echo "yes it is armstrong number";
}
else {
echo"no it is not armstrong number";
}
?>
</body>
</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 2

AIM : WAP to calculate the sum of series 1+11+111+…….

INPUT
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
echo "sum of series 1+11+111+... : <br>";
$temp=0;
$sum=0;
for($i=1;$i<5;$i++)
{
$temp=($temp*10)+1;
echo $temp;
echo"+";
if(10-1)
{
$sum=$sum+$temp;
}
}
Echo”<br>$sum”;
?
</body>
</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 3

AIM : Find the factorial of a number.

INPUT:
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
echo "factorial of a number : ";
$fact=1;
for($i=1;$i<6;$i++)
{
$fact=$fact*$i;
}
echo $fact;
?>
</body>
</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 4

AIM : Find the sum of natural numbers from 1 to 10.

INPUT:

<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
echo "Sum of all natural numbers from 1-10 : ";
$sum=0;
for($i=1;$i<11;$i++)
{
$sum=$sum+$i;
}
echo $sum;
?>
</body>
</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 5

AIM : WAP to find the sum of natural numbers divided by the


factorial of all natural numbers .

INPUT :

<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
echo "Sum of natural numbers divided by the factorial of number : ";
$sum=0;
$fact=1;
for($i=1;$i<5;$i++)
{
$fact=$fact+$i;
$sum=$sum+(($i)/$fact);
}
echo $sum;
?>
</body>
</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 6

AIM : WAP THAT RETURN THE LENGTH OF THE STRING.

<!DOCTYPE html>

<html>

<body>

<?php

echo strlen("Hello");

?>

</body>

</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 7

AIM : WAP THAT FIND THE POSITION OF THE FIRST


OCCURRENCE OF "PHP" INSIDE THE STRING.

<!DOCTYPE html>

<html>

<body>

<?php

echo strpos("I love php, I love php too!","php");

?>

</body>

</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 8

AIM : WAP THAT REVERSE THE STRING "HELLO WORLD!".

<!DOCTYPE html>

<html>

<body>

<?php

echo strrev("Hello World!");

?>

</body>

</html>

OUTPUT
SARVAM FONIA ROLL.NO.171279002

PRACTICAL 9

AIM : WAP THAT CONVERT THE FIRST CHARACTER OF EACH


WORD TO UPPERCASE.

<!DOCTYPE html>

<html>

<body>

<?php

echo ucwords("hello world!");

?>

</body>

</html>

OUTPUT

You might also like