diff options
| author | Zhineng Li <[email protected]> | 2026-01-10 16:37:39 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-01-10 16:37:39 +0800 |
| commit | 49891f6bce29843f503b437c84d83cb787ecfa87 (patch) | |
| tree | 50bd44422a907b869a6d4839df436f37a35be36d /ch01/ex04-temp.c | |
| download | c-knr-exercises-49891f6bce29843f503b437c84d83cb787ecfa87.tar.gz c-knr-exercises-49891f6bce29843f503b437c84d83cb787ecfa87.zip | |
first commit
Diffstat (limited to 'ch01/ex04-temp.c')
| -rw-r--r-- | ch01/ex04-temp.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ch01/ex04-temp.c b/ch01/ex04-temp.c new file mode 100644 index 0000000..f78a191 --- /dev/null +++ b/ch01/ex04-temp.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +/* print Celsius-Fahrenheit table */ +int main() +{ + float celsius, fahr; + int lower, upper, step; + + lower = 0; + upper = 300; + step = 20; + + printf("%3s %6s\n", "C", "F"); + + celsius = lower; + while (celsius <= upper) { + fahr = celsius / (5.0/9.0) + 32.0; + printf("%3.0f %6.0f\n", celsius, fahr); + celsius = celsius + step; + } +} |
