Div (C)

From Wikipedia, the free encyclopedia

The correct title of this article is div. The initial letter is shown capitalized due to technical restrictions.

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 has a prototype as follows:

div_t div (int numerator, int denominator)

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

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

Where quot stores the quotient and rem stores the remainder.