finished 1-13
[KandRexercises.git] / celfahr.c
blob5aa139aef603c5a5cad84e69f62db2de39878a67
1 #include <stdio.h>
2 /* exercise 1-4 */
3 /* print Celsius-Fahrenheit 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 celsius = lower;
15 printf("C\tFahr\n");
16 while (celsius <= upper) {
17 fahr = (9.0/5.0) * celsius + 32.0;
18 printf("%3.0f %6.1f\n", celsius, fahr);
19 celsius = celsius + step;