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++ 3.0r4 - <b>div</b> 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);

   ANSI

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 <stdio.h>
   #include <stdlib.h>

   int 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 ");
       printf("is %d\n",answ.quot,answ.rem);
       return EXIT_SUCCESS;
   }

Return Value

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

See Also

   ldiv   ldiv


See Also: ldiv ldiv

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