ldiv - C stdlib.h

C examples for stdlib.h:ldiv

Type

function

From

<cstdlib>
<stdlib.h>

Description

Integral division

Prototype

ldiv_t ldiv (long int numer, long int denom);

Parameters

Parameter Description
numer Numerator.
denom Denominator.

Return Value

a ldiv_t structure, which has two members (in either order):

long int quot;   // quotient
long int rem;    // remainder

Demo Code


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

int main ()/*from   www . j ava  2  s.  co  m*/
{
  ldiv_t ldivresult;
  ldivresult = ldiv (1100000L,132L);
  printf ("1100000 div 132 => %ld, remainder %ld.\n", ldivresult.quot, ldivresult.rem);
  return 0;
}

Related Tutorials