2 /* exercise 1-15: exercise 1-3 but with a function */
3 /* print Fahrenheit-Celsius table
4 for fahr = 0, 20, ..., 300; floating-point version */
5 int fahrc(float lower
, float upper
, float step
)
10 for (i
= lower
; i
<=upper
; i
+= step
)
11 printf("%3.0f %6.1f\n", i
, ((5.0/9.0) * (i
-32.0)));
19 float lower
, upper
, step
;
21 lower
= 0; /* lower limit of temperatuire scale */
22 upper
= 300; /* upper limit */
23 step
= 20; /* step size */
24 fahrc(lower
, upper
, step
);
28 while (fahr <= upper) {
29 celsius = (5.0/9.0) * (fahr-32.0);
30 printf("%3.0f %6.1f\n", fahr, celsius);