This is a basic PHP program based on arithmetic operators which explain to **subtract two numbers without using arithmetic operators** in PHP with an example and output.

Copy the below PHP code and execute it with help of **PHP compiler**.

PHP

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function subtract($x, $y) { while ($y != 0) { $borrow = (~$x) & $y; $x = $x ^ $y; $y = $borrow << 1; } return $x; } $x = 29; $y = 13; echo "x - y is ", subtract($x,$y); |

x – y is 16

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- PHP Program to print mirror image of Swastika Pattern
- PHP program to print identity matrix
- Formula based PHP program to find sum of all divisors of n
- PHP Program to find sum of even index term
- PHP Program to add two numbers without using arithmetic operator
- PHP Program of finding nth Delannoy Number
- Dynamic Programming solution for subset sum problem
- How to Print Triangle of Stars in PHP
- Print Triangle of Character Pattern in PHP
- PHP date_format() function with example