PHP program to enter two numbers and perform all arithmetic operations
ADVERTISEMENTS
PHP program to enter two numbers and perform all arithmetic operations.
There are you will learn how to perform all arithmetic operations in PHP language.
Let us understand this through the PHP program:
<?php
// PHP program to perform all arithmetic operations
$p = 5;
$q = 7;
$sum = 0;
$sub = 0;
$mul = 0;
$div = 0;
$mod = 0;
$sum = $p + $q;
$sub = $p - $q;
$mul = $p * $q;
$div = $p / $q;
$mod = $p % $q;
echo "\n";
echo "SUM " . $p . " + " . $q . " = " . $sum . "\n";
echo "DIFFERENCE " . $p . " - " . $q . " = " . $sub . "\n";
echo "PRODUCT " . $p . " * " . $q . " = " . $mul . "\n";
echo "QUOTIENT " . $p . " / " . $q . " = " . $div . "\n";
echo "MODULUS " . $p . " % " . $q . " = " . $mod . "\n";
?>
Output:
SUM 5 + 7 = 12
DIFFERENCE 5 - 7 = -2
PRODUCT 5 * 7 = 35
QUOTIENT 5 / 7 = 0.71428571428571
MODULUS 5 % 7 = 5