5. (A) Write a PHP Program to accept a number from the user and print it factorial.

5. (A) Write a PHP Program to accept a number from the user and print it factorial.

<html>
<body>
<h1>Factorial program in PHP</h1>
<!--form post method-->
<form action=""method="post">
<label>Enter Number To Calculate Factorial</label>
<input type="text"name="number"size="2"/>
</form>
</body>
</html>
<?php
if($_POST)
{
$fact=1;
$number=$_POST['number'];
echo"factorial of $number:<br><br>";
for($i=1;$i<=$number;$i++)
{
$fact=$fact*$i;
}
print$fact;
}
?>
5. (A) Write a PHP Program to accept a number from the user and print it factorial. 5. (A) Write a PHP Program to accept a number from the user and print it factorial. Reviewed by admin on December 24, 2019 Rating: 5

No comments:

Powered by Blogger.