Go to the first, previous, next, last section, table of contents.


div

Syntax

#include <stdlib.h>

div_t div(int numberator, int denomonator);

Description

Returns the quotient and remainder of the division numberator divided by denomonator. The return type is as follows:

typedef struct {
  int quot;
  int rem;
} div_t;

Return Value

The results of the division are returned.

Portability

ANSI, POSIX

Example

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 }


Go to the first, previous, next, last section, table of contents.