CodeCogs
HomeForumsCart
Login



Forgotten Password?

Or login with:

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

div

Return quotient and remainder from division

Interface

#include <stdlib.h>
div_t div (int num, int denom)

Description

The div function computes the value \c num/denom and returns the quotient and remainder in a structure named \c div_t that contains two <span class="Vt">int</span> members named <span class="Va">quot</span> and <span class="Va">rem</span>.

Example 1

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  int a = 100, b = 13;
  div_t result = div(a, b);
  printf("100 = 13*%d + %d\n", result.quot, result.rem);
  return 0;
}

Output:
100 = 13*7 + 9

Last Modified: 18 Dec 11 @ 14:15     Page Rendered: 2022-03-14 15:48:28