Yktula - 2 months ago 5x

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

Source (Stackoverflow)

Comments