doing first temperature exercise

This commit is contained in:
Brian 2024-03-25 15:29:43 -06:00
parent 5ac6873207
commit 40f999d693
Signed by: brian
GPG Key ID: 5032868E98A381FA
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,2 @@
all:
gcc -o temperature-table.x86_64 main.c

View 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;
}
}