Borland C++ reference

div

raw OCR

Divides two integers, returning quotient and remainder.

Defined in header <stdlib.h>

Syntax

#include <stdlib.h>
div_t div(int numer, int denom);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

div divides two integers and returns both the quotient and the remainder as a divjt type, numer and denom are the numerator and denominator, respectively. The divj type is a structure of integers defined (with typedef) in stdlib.h as follows:

typedef struct {

int quot;/* quotient */
int rem; } div_t;/* remainder */

Return value

div returns a structure whose elements are quot (the quotient) and rem (the remainder).

See also

Example

#include <stdlib.h>
#include <stdio.h>

div_t x;
int main(void)
{
   X = div(10,3);
   printfC'lO div 3   *d remainder %d\n", x.quot, x.rem);
   return 0;
}

Program   output

10 div 3=3   remainder 1

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.