-
Notifications
You must be signed in to change notification settings - Fork 1
/
4.c
36 lines (30 loc) · 791 Bytes
/
4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
/**
* Print Celsius-Fahrenheit Table with header.
* for fahr = 0, 20, ..., 300;
*
* Floating-point version.
*/
main()
{
float fahr, celsius;
float lower, upper, step;
/* lower limit of temperatuire scale */
lower = 0;
/* upper limit */
upper = 300;
/* step size */
step = 20;
fahr = lower;
/* Print table header */
printf("|------------------------------|\n");
printf("| Celsius | Fahrenheit |\n");
printf("|------------------------------|\n");
while (fahr <= upper) {
celsius = (5.0/9.0) * (fahr-32.0);
printf("| %6.1f | %3.0f |\n", celsius, fahr);
fahr = fahr + step;
}
/* Print table footer */
printf("|------------------------------|\n");
}