From 0a2043ca1f04532b03e39f25038a19167f41a958 Mon Sep 17 00:00:00 2001 From: Hugh Mungus Date: Thu, 28 Jul 2022 15:13:44 -0400 Subject: [PATCH] started on 1-15 --- 1-15.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 1-15.c diff --git a/1-15.c b/1-15.c new file mode 100644 index 0000000..e8a74c5 --- /dev/null +++ b/1-15.c @@ -0,0 +1,23 @@ +#include + /* exercise 1-15: Fahrenheit-Celsius table but with a function */ + /* print Fahrenheit-Celsius table + for fahr = 0, 20, ..., 300; floating-point version */ + +main() +{ + float fahr, celsius; + float lower, upper, step; + + lower = 0; /* lower limit of temperatuire scale */ + upper = 300; /* upper limit */ + step = 20; /* step size */ + + fahr = lower; + printf("Fahr\tC\n"); + while (fahr <= upper) { + celsius = (5.0/9.0) * (fahr-32.0); + printf("%3.0f %6.1f\n", fahr, celsius); + fahr = fahr + step; + } + +} -- 2.11.4.GIT