C examples for stdlib.h:ldiv
function
<cstdlib> <stdlib.h>
Integral division
ldiv_t ldiv (long int numer, long int denom);
Parameter | Description |
---|---|
numer | Numerator. |
denom | Denominator. |
a ldiv_t structure, which has two members (in either order):
long int quot; // quotient long int rem; // remainder
#include <stdio.h> #include <stdlib.h> int main ()/*from www . j ava 2 s. co m*/ { ldiv_t ldivresult; ldivresult = ldiv (1100000L,132L); printf ("1100000 div 132 => %ld, remainder %ld.\n", ldivresult.quot, ldivresult.rem); return 0; }