Skip to content

Commit

Permalink
Merge pull request rathoresrikant#531 from lharinarayanan/maxof2number
Browse files Browse the repository at this point in the history
maxof2numbers
  • Loading branch information
Srikant Singh authored Oct 27, 2018
2 parents 1e9a698 + f59f218 commit 9e0aef6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions maxandminof2numbers.php
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);


?>

0 comments on commit 9e0aef6

Please sign in to comment.