From 22e879750bfb7bc80f409ac1a083ce3f7ae006d8 Mon Sep 17 00:00:00 2001 From: Cian Bagshaw Date: Sun, 7 May 2023 07:30:22 +0100 Subject: [PATCH] 1-15 --- 1/15.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 1/15.c 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)); +} -- 2.20.1