30 lines
574 B
C
30 lines
574 B
C
#include <stdio.h>
|
|
|
|
/* print farenheit-celsius table
|
|
* for fahr = 0, 20, ..., 300 */
|
|
|
|
int main()
|
|
{
|
|
float fahr, celsius;
|
|
float lower, upper, step;
|
|
|
|
lower = 0; /* lower bound of temp scale*/
|
|
upper = 300; /* upper bound of temp scale*/
|
|
step = 20; /* step size between calculated conversions*/
|
|
|
|
fahr = lower;
|
|
|
|
|
|
printf("Temperature conversion table with 20-degree^f steps. \n");
|
|
printf("%4s\t%6s\n", "DegF", "DegC");
|
|
|
|
while (fahr <= upper)
|
|
{
|
|
celsius = (5.0/9.0) * (fahr-32);
|
|
printf("%4.0f\t%6.1f\n", fahr, celsius);
|
|
fahr = fahr + step;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|