Q:

Write a PHP program that accept two integers and return true if either one is 5 or their sum or difference is 5

0

Write a PHP program that accept two integers and return true if either one is 5 or their sum or difference is 5

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 == 5 || $y == 5 || $x + $y == 5 || abs($x - $y) == 5;
 }

var_dump(test(5, 4));
var_dump(test(4, 3));
var_dump(test(1, 4));

Sample Output:

bool(true)
bool(false)
bool(true)

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