1 /*Exercise 1-3. Modify the temperature conversion program to print a heading above the table.*/
2 #include <stdio.h>
3
4 /* print Fahrenheit-Celsius table
5 for fahr = 0, 20, ..., 300; floating-point version */
6 main()
7 {
8 float fahr, celsius;
9 int lower, upper, step;
10
11 lower = 0; /* lower limit of temperatuire scale */
12 upper = 300; /* upper limit */
13 step = 20; /* step size */
14
15 printf("fahr celsius\n");
16
17 fahr = lower;
18 while (fahr <= upper) {
19 celsius = (5.0/9.0) * (fahr-32.0);
20 printf("%4.0f %7.1f\n", fahr, celsius);
21 fahr = fahr + step;
22 }
23 }