Yktula - 9 months ago 39

C Question

How can we implement the modulo operator as a function in C without using the operator?

Answer

Simple:

If the quotient

`a/b`

is representable, the expression`(a/b)*b + a%b`

shall equal`a`

(C99 standard, 6.5.5/6).