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**.

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

- 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
- PHP strtotime function with the example

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok