started on 1-15
[KandRexercises.git] / 1-15.c
blobe8a74c5242945d4893ebd253a2a9f29617cf22d6
1 #include <stdio.h>
2 /* exercise 1-15: Fahrenheit-Celsius table but with a function */
3 /* print Fahrenheit-Celsius table
4 for fahr = 0, 20, ..., 300; floating-point version */
6 main()
7 {
8 float fahr, celsius;
9 float lower, upper, step;
11 lower = 0; /* lower limit of temperatuire scale */
12 upper = 300; /* upper limit */
13 step = 20; /* step size */
15 fahr = lower;
16 printf("Fahr\tC\n");
17 while (fahr <= upper) {
18 celsius = (5.0/9.0) * (fahr-32.0);
19 printf("%3.0f %6.1f\n", fahr, celsius);
20 fahr = fahr + step;