home *** CD-ROM | disk | FTP | other *** search
- /* divtest.c (emx+gcc) */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- void div_test (int num, int den, int xquot, int xrem)
- {
- div_t q;
-
- q = div (num, den);
- printf ("num=%d den=%d: quot=%d rem=%d", num, den, q.quot, q.rem);
- if (q.quot != xquot || q.rem != xrem)
- printf ("<--- ERROR");
- putchar ('\n');
- }
-
-
- int main (void)
- {
- div_test ( 0, 2, 0, 0);
- div_test ( 0, -2, 0, 0);
- div_test ( 5, 2, 2, 1);
- div_test ( 5, -2, -2, 1);
- div_test (-5, 2, -2, -1);
- div_test (-5, -2, 2, -1);
- return (0);
- }
-