User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed



    #include <stdlib.h>
    ldiv_t ldiv(long int numerator, long int denominator);

calculate the quotient and remainder in integer division (long integer).

ldiv C Sourcecode Example

 * ldiv c example code
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
#include <stdlib.h>
int main( void )
  long int numerator, denominator;
  printf("please type in (long int) numerator and denominator for ldiv\n");
  printf("(long int) numerator :");
  scanf("%li", &numerator);
  printf("(long int) denominator : ");
  scanf("%li", &denominator);
  ldiv_t result = ldiv(numerator, denominator);
  printf("%li = %li*%li + %li\n",numerator , denominator, result.quot, result.rem);
  return 0;


  user@host:~$ ./ldiv 
  please type in (long int) numerator and denominator for ldiv
  (long int) numerator :1234567890
  (long int) denominator : 1234
  1234567890 = 1234*1000460 + 250

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/ldiv.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz