Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    div_t div( int numer, int denom );

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

Description:
    The div function calculates the quotient and remainder of the division
    of the numerator numer by the denominator denom.

Returns:
    The div function returns a structure of type  div_t which contains the
    fields  quot and  rem.

See Also:
    ldiv

Example:
    #include <stdio.h>
    #include <stdlib.h>

    void print_time( int seconds )
      {
         auto div_t min_sec;

         min_sec = div( seconds, 60 );
         printf( "It took %d minutes and %d seconds\n",
                  min_sec.quot, min_sec.rem );
      }

    void main()
      {
        print_time( 130 );
      }

    produces the following:

    It took 2 minutes and 10 seconds

Classification:
    ANSI

Systems:
    All

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