Q:

Write a PHP program to check if it is possible to add two integers to get the third integer from three given integers

0

Write a PHP program to check if it is possible to add two integers to get the third integer from three given integers

All Answers

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

<?php
function test($x, $y, $z)
{
   return $x == $y + $z || $y == $x + $z || $z == $x + $y;
}

var_dump(test(1, 2, 3))."\n";
var_dump(test(4, 5, 6))."\n";
var_dump(test(-1, 1, 0))."\n";

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