User Tools

Site Tools


c:stdlib.h:ldiv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdlib.h:ldiv [2024/02/16 01:04] (current)
Line 1: Line 1:
 +    
 +{{keywords>wiki library source code example reference}}
 +====== ldiv ======
 +<code c>
 +    #include <stdlib.h>
 +    ldiv_t ldiv(long int numerator, long int denominator);
 +</code>    
 +    calculate the quotient and remainder in integer division (long integer).
 +
 +===== ldiv C Sourcecode Example =====    
 +<code c>
 +/* 
 + * ldiv c example code
 + * http://code-reference.com/c/stdlib.h/ldiv 
 + */
 +#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;
 +}
 +
 +</code>
 +
 +==== Output ====
 +
 +    Output:
 +    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