From: Cian Bagshaw Date: Tue, 29 Nov 2022 09:09:44 +0000 (+0000) Subject: Added exercise 1-4 X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;h=121094ba3edbb7f0e00f8e7b57281cbe4c2c25f7;p=cProgLang Added exercise 1-4 --- 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; + } +}