User Tools

Site Tools


c:stdlib.h:div

Differences

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

Link to this comparison view

c:stdlib.h:div [2024/02/16 01:04] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +====== div ======
 +<code c>
 +    #include <stdlib.h>
 +    div_t div(int numerator, int denominator);
 +</code>    
 +    calculates the quotient and remainder from division.
 +
 +===== div C Sourcecode Example =====    
 +<code c>
 +/* 
 + * div c example code
 + * http://code-reference.com/c/stdlib.h/div 
 + */
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +#include <stdlib.h>
 +
 +int main( void )
 +{
 +  int numerator, denominator;
 +  printf("please type in numerator and denominator for div\n");
 +  printf("numerator :");
 +  scanf("%d", &numerator);
 +
 +  printf("denominator : ");
 +  scanf("%d", &denominator);
 +
 +  div_t result = div(numerator, denominator);
 +
 +  printf("%d = %d*%d + %d\n",numerator , denominator, result.quot, result.rem);
 +  return 0;
 +}
 +
 +</code>
 +
 +==== Output ====
 +
 +    Output:
 +    user@host:~$ ./div 
 +    numerator : 2600
 +    denominator : 42
 +    2600 = 42*61 + 38
 +
 +
  

on the occasion of the current invasion of Russia in Ukraine

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

Impressum Datenschutz