C examples for stdlib.h:div
function
<cstdlib> <stdlib.h>
Returns the integral quotient and remainder of numer/denom as a structure of type div_t, ldiv_t or lldiv_t, which has two members:quot and rem.
lldiv_t div (long long int numer, long long int denom); div_t div (int numer, int denom); ldiv_t div (long int numer, long int denom);
Parameter | Description |
---|---|
numer | Numerator. |
denom | Denominator. |
a structure of type div_t, ldiv_t or lldiv_t, which has two members:quot and rem.
int quot; // quotient int rem; // remainder
#include <stdio.h> #include <stdlib.h> int main ()//from ww w .ja v a 2 s . co m { div_t divresult; divresult = div (8,5); printf ("8 div 5 => %d, remainder %d.\n", divresult.quot, divresult.rem); return 0; }