Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - div http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   div

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

   Description
   div  divides the numerator by denominator, returning the quotient  and
   the remainder. The div_t type is defined in stdlib.h as follows:

   typedef struct { int quot, rem; } div_t;

   Example
   #include <stdlib.h>
   main()
   {
   div_t answ;
   int ina,inb;
        puts("Enter two integers:");
        scanf("%d %d",&ina,&inb);
        answ = div(ina,inb);
        printf("The quotient is %d, and the remainder"
               "is %d\n", answ.quot,answ.rem);
   }

   Return Value
   The  div  function returns a structure type div_t whose  elements  are
   quot (the quotient) and rem (the remainder).


See Also: ldiv

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