about summary refs log tree commit diff stats
path: root/1.2.c
diff options
context:
space:
mode:
authoraabacchus <ben@bvnf.space>2021-05-19 00:11:26 +0100
committeraabacchus <ben@bvnf.space>2021-05-19 00:11:26 +0100
commit3a14f3cf7a1bd094ae73a4d2ca151464a9eda224 (patch)
tree21ca13dd11b0ea7f79feb110b954050b1656bf7a /1.2.c
downloadkandr-3a14f3cf7a1bd094ae73a4d2ca151464a9eda224.tar.gz
might as well make commits out of these
Diffstat (limited to '1.2.c')
-rw-r--r--1.2.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/1.2.c b/1.2.c
new file mode 100644
index 0000000..9614161
--- /dev/null
+++ b/1.2.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LOWER 0
+#define UPPER 300
+#define STEP  20
+
+int main() {
+    float fahr;
+    size_t fahrs;
+    void *fahrp;
+    fahrs = sizeof(float);
+    fahrp = malloc(fahrs);
+    fahr = 0;
+    printf("value:%f size:%d pointer: %p\n", fahr, fahrs, fahrp);
+
+    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.);
+    }
+    free(fahrp);
+    return 0;
+}