Write a PHP program to check three given integers and return true if one of them is 20 or more less than one of the others

  • برمجة بي اتش بي

Write a PHP program to check three given integers and return true if one of them is 20 or more less than one of the others

الأجوبة

<?php
function test($x, $y, $z)
{
    return abs($x - $y) >= 20 || abs($x - $z) >= 20 ||
                  abs($y - $z) >= 20;
}

var_dump(test(11, 21, 31))."\n";
var_dump(test(11, 22, 31))."\n";
var_dump(test(10, 20, 15))."\n";

Sample Output:

bool(true)
bool(true)
bool(false)
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...