Implemented the objectives of Exercise 1-3 to ex1_1-tempconverter.c and then implemented the objectives of Exercises 1-3 and 1-4 to ex1_4-tempconvertercf.c.

This commit is contained in:
Reina Harrington-Affine 2025-07-29 14:44:47 -07:00
parent 357347ae6e
commit 44dff59271
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,26 @@
#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;
}

BIN
KNR C/ex1_4.out Executable file

Binary file not shown.