Project-Scylla/KNR C/ex1_4-tempconvertercf.c

27 lines
518 B
C
Raw Permalink Normal View History

#include <stdio.h>
/*Implementation of exercise 1-4*/
/*Iteration on exercise 1-1 implementing a table converting from C to F*/
int main()
{
float fahr, celsius;
float lower, upper, step;
lower = -100;
upper = 200;
step = 10;
celsius = lower;
printf("Temperature conversion table, C->F, 5-degree^C steps. \n");
printf("%6s\t%6s\n", "Temp C", "Temp F");
while (celsius <= upper)
{
fahr = (celsius + 32) * (5.0/9.0);
printf("%6.0f\t%6.1f\n", celsius, fahr);
celsius = celsius + step;
}
return 0;
}