forked from rathoresrikant/HacktoberFestContribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rathoresrikant#531 from lharinarayanan/maxof2number
maxof2numbers
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// PHP program to Compute the minimum | ||
// or maximum of two integers without | ||
// branching | ||
|
||
// Function to find minimum | ||
// of x and y | ||
function m_in($x, $y) | ||
{ | ||
return $y ^ (($x ^ $y) & | ||
- ($x < $y)); | ||
} | ||
|
||
// Function to find maximum | ||
// of x and y | ||
function m_ax($x, $y) | ||
{ | ||
return $x ^ (($x ^ $y) & | ||
- ($x < $y)); | ||
} | ||
|
||
// Driver Code | ||
$x = 15; | ||
$y = 6; | ||
echo"Minimum of"," ", $x," ","and", | ||
" ",$y," "," is "," "; | ||
|
||
echo m_in($x, $y); | ||
|
||
echo "\nMaximum of"," ",$x," ", | ||
"and"," ",$y," ", " is "; | ||
|
||
echo m_ax($x, $y); | ||
|
||
|
||
?> |