From 675835c9b7c4fdc0212701c7f7d90d7c17d4a384 Mon Sep 17 00:00:00 2001 From: Hugh Mungus Date: Fri, 29 Jul 2022 11:51:51 -0400 Subject: [PATCH] finished 1-15 --- 1-15.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/1-15.c b/1-15.c index e8a74c5..d7e3142 100644 --- a/1-15.c +++ b/1-15.c @@ -1,7 +1,17 @@ #include - /* exercise 1-15: Fahrenheit-Celsius table but with a function */ + /* exercise 1-15: exercise 1-3 but with a function */ /* print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300; floating-point version */ +int fahrc(float lower, float upper, float step) +{ + float i; + + printf("Fahr\tC\n"); + for (i = lower; i <=upper; i += step) + printf("%3.0f %6.1f\n", i, ((5.0/9.0) * (i-32.0))); + + return 0; +} main() { @@ -11,13 +21,14 @@ main() lower = 0; /* lower limit of temperatuire scale */ upper = 300; /* upper limit */ step = 20; /* step size */ + fahrc(lower, upper, step); - fahr = lower; + /*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