function

lldiv

<cstdlib>
lldiv_t ldiv ( long long int numer, long long int denom );
Integral division
Returns the integral quotient and remainder of the division of numer by denom ( numer/denom ) as a structure of type lldiv_t, which has two members: quot and rem.

Parameters

numer
Numerator.
denom
Denominator.

Return Value

The result is returned by value in a lldiv_t structure, which has two members (in either order):
1
2
long long int quot;   // quotient
long long int rem;    // remainder 


Example

1
2
3
4
5
6
7
8
9
10
11
/* lldiv example */
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  lldiv_t res;
  res = lldiv (31558149LL,3600LL);
  printf ("Earth orbit: %lld hours and %lld seconds.\n", res.quot, res.rem);
  return 0;
}


Output:

Earth orbit: 8766 hours and 549 seconds.

See also