Yktula - 4 months ago 9

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