Write a PHP program to get the absolute difference between n and 51. If n is greater than 51 return triple the absolute difference

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

Write a PHP program to get the absolute difference between n and 51. If n is greater than 51 return triple the absolute difference.

الأجوبة

<?php
function test($n) 
{
     $x = 51;

     if ($n > $x)
     {
       return ($n - $x)*3;
     }
   return $x - $n;
}
echo test(53)."\n";
echo test(30)."\n";
echo test(51)."\n";
 Sample Output:
6
21
0
هل كان المحتوى مفيد؟

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

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