Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>div() divide two integers</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 div()                   Divide Two Integers

 #include   <stdlib.h>

 div_t      div(numer,denom);
 int numer;
 int denom;

    div() divides two integers, the numerator 'numer' and the denominator
    'denom'.  The result is returned in the structure div_t which is
    defined in <stdlib.h>:

     typdef struct {
          int  quot;               /* quotient */
          int  rem;                /* remainder */
     } div_t;

       Returns:     The structure div_t whose elements are the result of
                    the divide performed: the quotient 'quot' and the
                    remainder 'rem'.

   -------------------------------- Example ---------------------------------

    The following statements divide two integers and print the result.

           #include <stdlib.h>

           main()
           {
               div_t rslt;
               int num = 5000, den = 256;

               rslt = div(num,den);
               printf("%d div %d = %d",num,den,rslt.quot);
               if (rslt.rem != 0)
                   printf(", remainder %d\n",rslt.rem);
           }


See Also: ldiv()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson