Yktula - 5 months ago 24

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).