User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdlib.h:div

Table of Contents

div

    #include <stdlib.h>
    div_t div(int numerator, int denominator);

calculates the quotient and remainder from division.

div C Sourcecode Example

/* 
 * 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;
}

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