From 121094ba3edbb7f0e00f8e7b57281cbe4c2c25f7 Mon Sep 17 00:00:00 2001 From: Cian Bagshaw Date: Tue, 29 Nov 2022 09:09:44 +0000 Subject: [PATCH] Added exercise 1-4 --- 1/4.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 1/4.c diff --git a/1/4.c b/1/4.c new file mode 100644 index 0000000..2f8bf10 --- /dev/null +++ b/1/4.c @@ -0,0 +1,27 @@ +/* + Exercise 1-4. Write a program to print the corresponding Celcius to Fahrenheit + table. + === + + F = C(9/5)+32 +*/ + +#include + +int main () { + float fahr, cels; + + int lower = 0; + int upper = 300; + int step = 20; + + puts("Celsius to Fahrenheit"); + puts(" C F"); + + cels = lower; + while (cels <= upper) { + fahr = (cels * (9.0/5.0)) + 32; + printf("%3.0f %6.1f\n", cels, fahr); + cels += step; + } +} -- 2.20.1