From bfce8f0d0d828209ec0bec71371ee94a7ad62d3e Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Tue, 4 Jul 2023 17:03:53 -0500 Subject: Initial commit --- one/temp.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 one/temp.c (limited to 'one/temp.c') diff --git a/one/temp.c b/one/temp.c new file mode 100644 index 0000000..54c99ba --- /dev/null +++ b/one/temp.c @@ -0,0 +1,31 @@ +#include + +#define LOWER 0 +#define UPPER 300 +#define STEP 20 + +void +temp() +{ + float fahr, cel; + + printf("Fahrenheit-Celsius table\n"); + for (fahr = UPPER; fahr >= LOWER; fahr -= STEP) { + cel = (5.0 / 9.0) * (fahr - 32.0); + /* 3 and 6 characters wide with 1 digit after the dot */ + printf("%3.0f %6.1f\n", fahr, cel); + } + + printf("\nCelsius-Fahrenheit table\n"); + for (cel = LOWER; cel <= UPPER; cel += STEP) { + fahr = 9.0 / 5.0 * cel + 32.0; + printf("%3.0f %6.0f\n", cel, fahr); + } +} + +int +main() +{ + temp(); + return 0; +} -- cgit v1.2.3