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