PHP = Write a program that inputs a pair of number num1 and num2 and divide the larger of the two by smaller.
Note: it will first be necessary to test for a zero value, since divide by zero will cause program to halt immediately.
Reactions: |
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete$num1=$_POST['n1'];
ReplyDelete$num2=$_POST['n2'];
echo "The two numbers entered are: $num1 $num2";
echo "
";
if($num2==0||$num1==0)
{
echo "Demoninator cant be zero";
}
else if($num1>$num2)
{
$n=$num1/$num2;
echo "The calculation is: ".$n;
echo "
";
}
else if($num1<$num2)
{
$n=$num2/$num1;
echo "The calculation is: ".$n;
echo "
";
}
php
Delete$num1=$_POST['n1'];
$num2=$_POST['n2'];
if($num2==0)
echo"division is not possible";
else if ($num1>$num2)
{$num=$num1/$num2;
echo "$num";
}
else
{$num=$num2/$num1;
echo "$num";
}
$num1=$_POST["n1"];
ReplyDelete$num2=$_POST["n2"];
if($num1==0||$num2==0)
{
echo "Can't divide";
break;
if($num1>$num2)
{
echo $num1/$num2;
}
else
{
echo $num2/$num1;
}
This comment has been removed by the author.
ReplyDelete?php
ReplyDelete$n1=$_post["num1"];
$n2=$_post["num2"];
if(n1>0 && n2>0)
{if(n1>=n2)
{$o=n1/n2;
echo"output:"."$o"}
else
if(n2>=n1)
{$o=n2/n2;
echo"output:"."$o";}
}else
echo"program not accepted zero value";
?>