CodeCogs
HomeForumsCart
Login



Forgotten Password?

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
ComputingCStdlib.h

ldiv

Return quotient and remainder from division

Interface

#include <stdlib.h>
ldiv_t ldiv (long num, long denom)

Description

The ldiv function computes the value num denom and returns the quotient and remainder in a structure named ldiv_t that contains two long members named quot and rem.

Example 1

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  long a = 2147111222, b = 1234;
  ldiv_t result = ldiv(a, b);
  printf("2147111222 = 1234*%ld + %ld\n", result.quot, result.rem);
  return 0;
}

Output:
2147111222 = 1234*1739960 + 582

Last Modified: 18 Dec 11 @ 14:44     Page Rendered: 2022-03-14 15:49:34