home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / emx / test / divtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  550 b   |  28 lines

  1. /* divtest.c (emx+gcc) */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. void div_test (int num, int den, int xquot, int xrem)
  7. {
  8.   div_t q;
  9.  
  10.   q = div (num, den);
  11.   printf ("num=%d den=%d: quot=%d rem=%d", num, den, q.quot, q.rem);
  12.   if (q.quot != xquot || q.rem != xrem)
  13.     printf ("<--- ERROR");
  14.   putchar ('\n');
  15. }
  16.  
  17.  
  18. int main (void)
  19. {
  20.   div_test ( 0,  2,  0,  0);
  21.   div_test ( 0, -2,  0,  0);
  22.   div_test ( 5,  2,  2,  1);
  23.   div_test ( 5, -2, -2,  1);
  24.   div_test (-5,  2, -2, -1);
  25.   div_test (-5, -2,  2, -1);
  26.   return (0);
  27. }
  28.