Write a PHP program to check if a given number is within 2 of a multiple of 10.
<?php function test($n) { return $n % 10 <= 2 || $n % 10 >= 8; } var_dump(test(3)); var_dump(test(7)); var_dump(test(8)); var_dump(test(21));
Sample Output:
bool(false) bool(false) bool(true) bool(true)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer