Yktula - 1 year ago 61

C Question

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

Answer Source

Simple:

If the quotient

`a/b`

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

shall equal`a`

(C99 standard, 6.5.5/6).