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

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

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

الأجوبة

<?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
هل كان المحتوى مفيد؟

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

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