summaryrefslogtreecommitdiff
path: root/ch01/ex03-temp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ch01/ex03-temp.c')
-rw-r--r--ch01/ex03-temp.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ch01/ex03-temp.c b/ch01/ex03-temp.c
new file mode 100644
index 0000000..b52e241
--- /dev/null
+++ b/ch01/ex03-temp.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+/* print Fahrenheit-Celsius table */
+int main()
+{
+ float fahr, celsius;
+ int lower, upper, step;
+
+ lower = 0;
+ upper = 300;
+ step = 20;
+
+ printf("%3s %6s\n", "F", "C");
+
+ fahr = lower;
+ while (fahr <= upper) {
+ celsius = (5.0/9.0) * (fahr-32.0);
+ printf("%3.0f %6.1f\n", fahr, celsius);
+ fahr = fahr + step;
+ }
+}