diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-09 17:50:39 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-09 17:50:39 -0700 |
| commit | 7d0d1de8117c51ba032cffe496bbbb122d008423 (patch) | |
| tree | 13cdaca7efb63e87b20af4eefe8ad750e175aeec | |
| parent | 55468623670a91bedb3164c10f5dc874e76be44f (diff) | |
complete exercise 1-3.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | src/1-3/fahrenheit_celsius.c | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f47cb20 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.out diff --git a/src/1-3/fahrenheit_celsius.c b/src/1-3/fahrenheit_celsius.c new file mode 100644 index 0000000..922506a --- /dev/null +++ b/src/1-3/fahrenheit_celsius.c @@ -0,0 +1,19 @@ +#include "stdio.h" + +int main() +{ + float fahr, celsius; + int lower, upper, step; + + lower = 0; + upper = 300; + step = 20; + + printf("Fahrenheit Celsius\n"); + fahr = lower; + while (fahr <= upper) { + celsius = (5.0/9.0) * (fahr-32.0); + printf("%10.0f %7.1f\n", fahr, celsius); + fahr = fahr + step; + } +} |
