doing first temperature exercise
This commit is contained in:
parent
5ac6873207
commit
40f999d693
2
chapter-01/temperature-io/Makefile
Normal file
2
chapter-01/temperature-io/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
all:
|
||||
gcc -o temperature-table.x86_64 main.c
|
18
chapter-01/temperature-io/main.c
Normal file
18
chapter-01/temperature-io/main.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define LOWER 0 /* lower limit of table */
|
||||
#define UPPER 300 /* upper limit of table */
|
||||
#define STEP 20 /* increment size */
|
||||
|
||||
int main()
|
||||
{
|
||||
float fahr, celsius, tModifier;
|
||||
|
||||
fahr = LOWER;
|
||||
tModifier = (5.0/9.0);
|
||||
while (fahr <= UPPER) {
|
||||
celsius = tModifier * (fahr - 32.0);
|
||||
printf("%3.0f\t%5.1f\n", fahr, celsius);
|
||||
fahr = fahr + STEP;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user