shoes2.c 687 B

1234567891011121314151617181920
  1. /* shoes2.c -- calculates foot lengths for several sizes */
  2. #include <stdio.h>
  3. #define ADJUST 7.31 // one kind of symbolic constant
  4. int main(void)
  5. {
  6. const double SCALE = 0.333; // another kind of symbolic constant
  7. double shoe, foot;
  8. printf("Shoe size (men's) foot length\n");
  9. shoe = 3.0;
  10. while (shoe < 18.5) /* starting the while loop */
  11. { /* start of block */
  12. foot = SCALE * shoe + ADJUST;
  13. printf("%10.1f %15.2f inches\n", shoe, foot);
  14. shoe = shoe + 1.0;
  15. } /* end of block */
  16. printf("If the shoe fits, wear it.\n");
  17. return 0;
  18. }