Q:

Write a PHP program to calculate the mod of two given integers without using any inbuilt modulus operator

0

Write a PHP program to calculate the mod of two given integers without using any inbuilt modulus operator.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function without_mod($m, $n)
{
   $divides=(int)($m/$n);
   return $m-$n*$divides;
}
echo without_mod(13, 2)."\n";
echo without_mod(81, 3)."\n";
?>

Sample Output:

1                                                           
0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now