Q:

Write a PHP program to compute the sum of the two given integers. If one of the given integer value is in the range 10..20 inclusive return 18

0

Write a PHP program to compute the sum of the two given integers. If one of the given integer value is in the range 10..20 inclusive return 18

All Answers

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

<?php
function test($x, $y)
{
   return ($x >= 10 && $x <= 20) || ($y >= 10 && $y <= 20) ? 18 : $x + $y;
 }

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

Sample Output:

10
18
18
241

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