C library functions - ldiv ()
C standard library - <stdlib.h>
description
C library functionsdiv_t div (long int numer, long int denom) the numer (numerator)divided bydenom (denominator).
statement
Here is () statement ldiv function.
div_t div(long int numer, long int denom)
parameter
- numer - molecules.
- denom - denominator.
return value
The function returns defined in <cstdlib> value in the structure, the structure has two members, such asldiv_t: long quot; long rem;.
Examples
The following example demonstrates ldiv () function is used.
#include <stdio.h> #include <stdlib.h> int main () { ldiv_t output; output = ldiv(100000L, 30000L); printf("商 = %ld\n", output.quot); printf("余数 = %ld\n", output.rem); return(0); }
Let's compile and run the above program, which will result in the following:
商 = 3 余数 = 10000