diff --git a/KNR C/ex1_4-tempconvertercf.c b/KNR C/ex1_4-tempconvertercf.c new file mode 100644 index 0000000..c773936 --- /dev/null +++ b/KNR C/ex1_4-tempconvertercf.c @@ -0,0 +1,26 @@ +#include +/*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; +} diff --git a/KNR C/ex1_4.out b/KNR C/ex1_4.out new file mode 100755 index 0000000..01a34ff Binary files /dev/null and b/KNR C/ex1_4.out differ