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

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

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

الأجوبة

<?php
function test($a, $b)
{
    return $a + $b >= 10 && $a +$b <= 20 ? 30 : $a + $b;
 }

echo test(12, 17)."\n";
echo test(2, 17)."\n";
echo test(22, 17)."\n";
echo test(20, 0)."\n";

Sample Output:

29
30
39
30
هل كان المحتوى مفيد؟

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

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