summaryrefslogtreecommitdiffstats
path: root/1/4.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-11-14 17:57:59 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-11-14 17:57:59 +0800
commit8cdb0c05bc3180660a6272e0b9423f66f233bc9b (patch)
tree51f41b7eb87471f86ecbc696db2464518f016ba6 /1/4.c
parent7acc722bc45f225fde82a6b1bc7729782bc79dfb (diff)
downloadk&r-exercises-8cdb0c05bc3180660a6272e0b9423f66f233bc9b.tar.gz
1.4
Diffstat (limited to '1/4.c')
-rw-r--r--1/4.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/1/4.c b/1/4.c
new file mode 100644
index 0000000..3416e02
--- /dev/null
+++ b/1/4.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ float celsius, fahr;
+ int lower, upper, step;
+
+ lower = 0;
+ upper = 300;
+ step = 20;
+ celsius = lower;
+
+ printf("celsius\tfahrenheit\n");
+
+ while (celsius <= upper) {
+ fahr = (9.0 * celsius / 5.0) + 32.0;
+ printf("%7.0f\t%10.1f\n", celsius, fahr);
+ celsius = celsius + step;
+ }
+
+ return 0;
+} \ No newline at end of file