diff options
author | Adam Carpenter <53hornet@gmail.com> | 2019-05-14 11:40:11 -0400 |
---|---|---|
committer | Adam Carpenter <53hornet@gmail.com> | 2019-05-14 11:40:11 -0400 |
commit | e0ac6e6a3c74f0e4d5936462eaae4d450fa3ed43 (patch) | |
tree | d24cf016b4996402e871e5d8da604a8e0e44b4fb /ftoc.c | |
parent | 610018231b17e990e56396eaea4912f1b112e1f2 (diff) | |
download | learning-c-e0ac6e6a3c74f0e4d5936462eaae4d450fa3ed43.tar.xz learning-c-e0ac6e6a3c74f0e4d5936462eaae4d450fa3ed43.zip |
Finished functions.
Diffstat (limited to 'ftoc.c')
-rw-r--r-- | ftoc.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -4,6 +4,8 @@ #define UPPER 300 // upper limit of table #define STEP 20 // step size +float ftoc(int fahr); + /* * Print Fahrenheit-Celcius table for fahr = 0, 20, ... 300. */ @@ -11,9 +13,9 @@ main() { float fahr, celcius; int lower, upper, step; - lower = 0; // lower limit of temperature table - upper = 300; // upper limit of temperature table - step = 20; // step size + lower = LOWER; // lower limit of temperature table + upper = UPPER; // upper limit of temperature table + step = STEP; // step size fahr = lower; @@ -26,7 +28,10 @@ main() { // } for (fahr = UPPER; fahr >= LOWER; fahr = fahr - STEP) { - printf("%3.0f %6.1f\n", fahr, (5.0 / 9.0) * (fahr - 32)); + printf("%3.0f %6.1f\n", fahr, ftoc(fahr)); } } +float ftoc(int fahr) { + return (5.0 / 9.0) * (fahr - 32); +} |