kandr

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit fb8250fa0c3f6d1f052d36219ad5e3fa0852b4d4
parent 68cd61de0e2d5bfb3f46d6c3a00cf29320ad2d56
Author: phoebos <ben@bvnf.space>
Date:   Mon, 21 Jun 2021 11:46:40 +0100

1-15: use a function for 1.2 temp conversion

Diffstat:
M1.2.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/1.2.c b/1.2.c @@ -5,6 +5,8 @@ #define UPPER 300 #define STEP 20 +float fahr_to_cel (float fahr); + int main() { float fahr; size_t fahrs; @@ -16,8 +18,12 @@ int main() { printf("%3s\t%6s\n", "F", "C"); for (fahr=UPPER; fahr >= LOWER; fahr -= STEP) { - printf("%3.0f\t%6.2f\n", fahr, 5. * (fahr - 32.) / 9.); + printf("%3.0f\t%6.2f\n", fahr, fahr_to_cel(fahr)); } free(fahrp); return 0; } + +float fahr_to_cel (float fahr) { + return 5.0 * (fahr - 32.0) / 9.0; +}