1-15
authorCian Bagshaw <cian@cianb.xyz>
Sun, 7 May 2023 06:30:22 +0000 (07:30 +0100)
committerCian Bagshaw <cian@cianb.xyz>
Sun, 7 May 2023 06:30:22 +0000 (07:30 +0100)
1/15.c [new file with mode: 0644]

diff --git a/1/15.c b/1/15.c
new file mode 100644 (file)
index 0000000..d608b87
--- /dev/null
+++ b/1/15.c
@@ -0,0 +1,18 @@
+/*
+       Exercise 1-15. Rewrite the temperature conversion program of Section 1.2
+       to use a function for conversion. 
+       ===
+*/
+
+#include <stdio.h>
+
+/* fahrenheit to celsius */ 
+float f2c (int f) {
+       return (5.0/9.0)*(f-32.0);
+}
+
+int main () {
+       int f;  /* fahrenheit */
+       for (f=0; f<=300; f+=20)
+               printf("%3d %6.1f\n", f, f2c(f));
+}