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:
parent
357347ae6e
commit
44dff59271
2 changed files with 26 additions and 0 deletions
26
KNR C/ex1_4-tempconvertercf.c
Normal file
26
KNR C/ex1_4-tempconvertercf.c
Normal 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
BIN
KNR C/ex1_4.out
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue