diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-11-19 19:01:38 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-11-19 19:01:38 +0800 |
| commit | 23c3318429f9d68803351e72b4389f59d15cad07 (patch) | |
| tree | 56d80d109c3eb9e8ec9fb0713a9142690dbd7c3a | |
| parent | c45c105e45e6d9954206a1ea93e5ed5bf21fe3bf (diff) | |
| download | k&r-exercises-23c3318429f9d68803351e72b4389f59d15cad07.tar.gz | |
1.15
| -rw-r--r-- | 1/15.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#include <stdio.h> + +/* converts fahrenhite to celsius */ +int ftoc(int fahr); + +int main(int argc, char *argv[]) { + int fahr, celsius; + int lower, upper, step; + + lower = 0; + upper = 300; + step = 20; + fahr = lower; + + while (fahr <= upper) { + printf("%d\t%d\n", fahr, ftoc(fahr)); + fahr += step; + } + + return 0; +} + +int ftoc(int fahr) { return 5 * (fahr - 32) / 9; }
\ No newline at end of file |
