From: Cian Bagshaw Date: Sun, 7 May 2023 06:30:22 +0000 (+0100) Subject: 1-15 X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;h=22e879750bfb7bc80f409ac1a083ce3f7ae006d8;p=cProgLang 1-15 --- diff --git a/1/15.c b/1/15.c new file mode 100644 index 0000000..d608b87 --- /dev/null +++ b/1/15.c @@ -0,0 +1,18 @@ +/* + Exercise 1-15. Rewrite the temperature conversion program of Section 1.2 + to use a function for conversion. + === +*/ + +#include + +/* fahrenheit to celsius */ +float f2c (int f) { + return (5.0/9.0)*(f-32.0); +} + +int main () { + int f; /* fahrenheit */ + for (f=0; f<=300; f+=20) + printf("%3d %6.1f\n", f, f2c(f)); +}