1
0

assert.c 457 B

123456789101112131415161718192021
  1. /* assert.c -- use assert() */
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <assert.h>
  5. int main()
  6. {
  7. double x, y, z;
  8. puts("Enter a pair of numbers (0 0 to quit): ");
  9. while (scanf("%lf%lf", &x, &y) == 2
  10. && (x != 0 || y != 0))
  11. {
  12. z = x * x - y * y; /* should be + */
  13. assert(z >= 0);
  14. printf("answer is %f\n", sqrt(z));
  15. puts("Next pair of numbers: ");
  16. }
  17. puts("Done");
  18. return 0;
  19. }