about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorphoebos <ben@bvnf.space>2021-06-21 11:46:40 +0100
committerphoebos <ben@bvnf.space>2021-06-21 11:46:40 +0100
commitfb8250fa0c3f6d1f052d36219ad5e3fa0852b4d4 (patch)
treef7a3f1bb08880c4267c776bfff4434aa80feb754
parent68cd61de0e2d5bfb3f46d6c3a00cf29320ad2d56 (diff)
downloadkandr-master.tar.gz
1-15: use a function for 1.2 temp conversion HEAD master
-rw-r--r--1.2.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/1.2.c b/1.2.c
index 9614161..f68573f 100644
--- a/1.2.c
+++ b/1.2.c
@@ -5,6 +5,8 @@
 #define UPPER 300
 #define STEP  20
 
+float fahr_to_cel (float fahr);
+
 int main() {
     float fahr;
     size_t fahrs;
@@ -16,8 +18,12 @@ int main() {
 
     printf("%3s\t%6s\n", "F", "C");
     for (fahr=UPPER; fahr >= LOWER; fahr -= STEP) {
-        printf("%3.0f\t%6.2f\n", fahr, 5. * (fahr - 32.) / 9.);
+        printf("%3.0f\t%6.2f\n", fahr, fahr_to_cel(fahr));
     }
     free(fahrp);
     return 0;
 }
+
+float fahr_to_cel (float fahr) {
+    return 5.0 * (fahr - 32.0) / 9.0;
+}