C Programming/stdlib.h/div

div is a function in C programming language that takes two integers as parameters and returns the result of a division between them. It is specified in ANSI-C, and is included from the stdlib.h header when used.

div always rounds towards 0, unlike ordinary integer division in C, where rounding for negative numbers is implementation-dependent.

has a prototype as follows:

The return value,  is a special datatype which is specifically used in storing the results of this function. It is defined as follows: Where  stores the quotient and   stores the remainder.

ldiv and lldiv are similar functions that divide integers of type  and , respectively; and return a structure of type   and  , respectively.