fct.c 515 B

123456789101112131415161718192021
  1. #include <stdio.h>
  2. /* print Fahrenheit-Celsius table
  3. for fahr = 0, 20, ..., 300; floating-point version */
  4. main()
  5. {
  6. float fahr, celsius;
  7. float lower, upper, step;
  8. lower = 0; /* lower limit of temperatuire scale */
  9. upper = 300; /* upper limit */
  10. step = 20; /* step size */
  11. fahr = lower;
  12. while (fahr <= upper) {
  13. celsius = (5.0/9.0) * (fahr-32.0);
  14. printf("%3.0f %6.99f\n", fahr, celsius);
  15. fahr = fahr + step;
  16. }
  17. }