div
div_t div ( int numer, int denom ); | stdlib.h |
cplusplus.com |
Divide two integer values.
numer is divided by denom. Quotient and remainder are returned
in a div_t structure.
Parameters.
Return Value.
A div_t structure is returned:
div_t structure is defined in stdlib.h and has two members of type int: quot representing the quotient, and rem representing the remainder.typedef struct { int quot; int rem; } div_t;
Portability.
Defined in ANSI-C.
Example.
/* div example */
#include <stdio.h>
#include <stdlib.h>
main ()
{
div_t divresult;
divresult = div (38,5);
printf ("38 / 5 = %d ( %d", divresult.quot, divresult.rem);
return 0;
}
Output:
38 / 5 = 7 ( 3
See also.
ldiv