| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <stdlib.h> div_t div(int numerator, int denominator); |
Returns the quotient and remainder of the division numerator divided by denominator. The return type is as follows:
typedef struct {
int quot;
int rem;
} div_t;
|
The results of the division are returned.
| ANSI/ISO C | C89; C99 |
| POSIX | 1003.2-1992; 1003.1-2001 |
div_t d = div(42, 3);
printf("42 = %d x 3 + %d\n", d.quot, d.rem);
div(+40, +3) = { +13, +1 }
div(+40, -3) = { -13, +1 }
div(-40, +3) = { -13, -1 }
div(-40, -3) = { +13, -1 }
|