]> zdv2.bktei.com Git - BK-2023-05.git/blob - src/kr_exercises/ch1/s1.2/f_to_c_float.c
update(src/kr):Complete exercise 1-7: print eof value
[BK-2023-05.git] / src / kr_exercises / ch1 / s1.2 / f_to_c_float.c
1 /* Desc: simple temperature converter
2 * Usage: ./s1..f_to_c_float.c
3 * Ref/Attrib: The C Programming Language, 2nd Edition, Section 1.2
4 */
5
6 #include <stdio.h>
7 //#include <stdlib.h>
8
9 /* print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300 */
10
11 int main(){
12 float fahr, celsius;
13 int lower, upper, step;
14
15 lower = 0; /* lower limit of temperature table */
16 upper = 300; /* upper limit */
17 step = 20; /* step size */
18
19 fahr = lower;
20 printf(" °F, °C\n");
21 while (fahr <= upper){
22 celsius = (5.0/9.0) * (fahr-32.0);
23 printf("%3.0f,%6.1f\n", fahr, celsius);
24 fahr = fahr + step;
25 };
26
27
28 printf("\n\nDone\n\n");
29 return 0;
30 };
31
32
33
34
35 /*
36 * Author: Steven Baltakatei Sandoval
37 * License: GPLv3+
38 */