diff options
Diffstat (limited to 'ch01/ex15-temp.c')
| -rw-r--r-- | ch01/ex15-temp.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ch01/ex15-temp.c b/ch01/ex15-temp.c new file mode 100644 index 0000000..e38bdf4 --- /dev/null +++ b/ch01/ex15-temp.c @@ -0,0 +1,25 @@ +#include <stdio.h> + +int ftoc(int lower, int upper, int step); + +/* print Fahrenheit-Celsius table */ +int main() +{ + ftoc(0, 300, 20); + return 0; +} + +/* ftoc: print Farenheit-Celsius table */ +int ftoc(int lower, int upper, int step) +{ + float fahr, celsius; + + fahr = lower; + while (fahr <= upper) { + celsius = (5.0/9.0) * (fahr-32.0); + printf("%3.0f %6.1f\n", fahr, celsius); + fahr = fahr + step; + } + + return 0; +} |
