From fbc5c728eab3096c5e7bd224b434ec80bb9e8363 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Tue, 30 Apr 2024 16:40:42 +0400 Subject: [PATCH] 1.15 --- The C Programming Language/1.15.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 The C Programming Language/1.15.c diff --git a/The C Programming Language/1.15.c b/The C Programming Language/1.15.c new file mode 100644 index 0000000..a53da8b --- /dev/null +++ b/The C Programming Language/1.15.c @@ -0,0 +1,24 @@ +#include + +double to_fahr(double celsius) +{ + return (celsius * 9.0 / 5.0) + 32.0; +} + +main() +{ + float fahr, celsius; + int lower, upper, step; + + lower = 0; + upper = 300; + step = 20; + + celsius = lower; + printf("%10s %7s\n", "Fahrenheit", "Celsius"); + while (celsius <= upper) + { + printf("%10.0f %7.1f\n", to_fahr(celsius), celsius); + celsius = celsius + step; + } +}