1
0

break.c 545 B

123456789101112131415161718192021
  1. /* break.c -- uses break to exit a loop */
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. float length, width;
  6. printf("Enter the length of the rectangle:\n");
  7. while (scanf("%f", &length) == 1)
  8. {
  9. printf("Length = %0.2f:\n", length);
  10. printf("Enter its width:\n");
  11. if (scanf("%f", &width) != 1)
  12. break;
  13. printf("Width = %0.2f:\n", width);
  14. printf("Area = %0.2f:\n", length * width);
  15. printf("Enter the length of the rectangle:\n");
  16. }
  17. printf("Done.\n");
  18. return 0;
  19. }