]> zdv2.bktei.com Git - BK-2023-05.git/blob - src/kr_exercises/ch1/s1.2/s1.2..f_to_c.c
e2ff1cfdb13a151a210dfb1a4ee412c8dbef57bb
[BK-2023-05.git] / src / kr_exercises / ch1 / s1.2 / s1.2..f_to_c.c
1 #include <stdio.h>
2
3 /* print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300 */
4
5 int main() {
6 int fahr, celsius;
7 int lower, upper, step;
8
9 lower = 0; /* lower limit of temperature table */
10 upper = 300; /* upper limit */
11 step = 20; /* step size */
12
13 fahr = lower;
14 while (fahr <= upper) {
15 celsius = 5 * (fahr-32) / 9;
16 printf("%d\t%d\n", fahr, celsius);
17 fahr = fahr + step;
18 }
19 }