26 lines
518 B
C
26 lines
518 B
C
#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;
|
|
}
|