Skip to content

Commit

Permalink
maxof2numbers
Browse files Browse the repository at this point in the history
Php code to generate the max and min of 2 numbers
  • Loading branch information
lharinarayanan committed Oct 27, 2018
1 parent 94ec316 commit f59f218
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 f59f218

Please sign in to comment.