summaryrefslogtreecommitdiffstats
path: root/1/15.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-11-19 19:01:38 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-11-19 19:01:38 +0800
commit23c3318429f9d68803351e72b4389f59d15cad07 (patch)
tree56d80d109c3eb9e8ec9fb0713a9142690dbd7c3a /1/15.c
parentc45c105e45e6d9954206a1ea93e5ed5bf21fe3bf (diff)
downloadk&r-exercises-23c3318429f9d68803351e72b4389f59d15cad07.tar.gz
1.15
Diffstat (limited to '1/15.c')
-rw-r--r--1/15.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/1/15.c b/1/15.c
new file mode 100644
index 0000000..3499ec7
--- /dev/null
+++ b/1/15.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+/* converts fahrenhite to celsius */
+int ftoc(int fahr);
+
+int main(int argc, char *argv[]) {
+ int fahr, celsius;
+ int lower, upper, step;
+
+ lower = 0;
+ upper = 300;
+ step = 20;
+ fahr = lower;
+
+ while (fahr <= upper) {
+ printf("%d\t%d\n", fahr, ftoc(fahr));
+ fahr += step;
+ }
+
+ return 0;
+}
+
+int ftoc(int fahr) { return 5 * (fahr - 32) / 9; } \ No newline at end of file