Q:

Write a PHP program to find the larger from two given integers

0

Write a PHP program to find the larger from two given integers. However if the two integers have the same remainder when divided by 7, then the return the smaller integer. If the two integers are the same, return 0

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function test($x, $y)
{
    if ($x == $y)
            {
                return 0;
            }
            else if (($x % 7 == $y % 7 && $x < $y) || $x > $y)
            {
                return $x;
            }
            else
            {
                return $y;
            }
}

echo test(11, 21)."\n";
echo test(11, 20)."\n";
echo test(10, 10)."\n";

Sample Output:

21
20
0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now