div() - return quotient and remainder from division
#include <stdlib.h>
div_t div (int num, int denom)
The div(3) function computes the value num and returns the quotient and remainder in a structure named div_t that contains two int members named quot and rem. If your application requires numbers to be rounded in the same way on all systems, use
div(a,b).quot
instead of
a/b
To get the remainder, use
div(a,b).rem
ldiv(3)