summaryrefslogtreecommitdiff
path: root/ctof.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctof.c')
-rw-r--r--ctof.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ctof.c b/ctof.c
new file mode 100644
index 0000000..7e2cbef
--- /dev/null
+++ b/ctof.c
@@ -0,0 +1,24 @@
+#include<stdio.h>
+
+/*
+ * Print Celcius-Fahrenheit table for celcius = 0, 20, ... 300.
+ */
+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
+
+ celcius = lower;
+
+ printf("%3s %6s\n", "C", "F");
+
+ while (celcius <= upper) {
+ fahr = (9.0 / 5.0) * celcius + 32.0;
+ printf("%3.0f %6.1f\n", celcius, fahr);
+ celcius = celcius + step;
+ }
+}
+