div() — Calculate quotient and remainder

Format

#include <stdlib.h>

div_t div(int numerator, int denominator);

General description

The div() function calculates the quotient and remainder of the division of numerator by denominator.

Returned value

The div() function returns a structure of type div_t, containing both the quotient int quot and the remainder int rem. This structure is defined in stdlib.h. If the returned value cannot be represented, the behavior of div() is undefined. If denominator is 0, a divide by 0 exception is raised.

Related Information