From 8cdb0c05bc3180660a6272e0b9423f66f233bc9b Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sun, 14 Nov 2021 17:57:59 +0800 Subject: 1.4 --- 1/3.c | 26 +++++++++++++------------- 1/4.c | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 1/4.c diff --git a/1/3.c b/1/3.c index 1360673..d0c8ea1 100644 --- a/1/3.c +++ b/1/3.c @@ -1,21 +1,21 @@ #include int main(int argc, char *argv[]) { - float fahr, celsius; - int lower, upper, step; + float fahr, celsius; + int lower, upper, step; - lower = 0; - upper = 300; - step = 20; - fahr = lower; + lower = 0; + upper = 300; + step = 20; + fahr = lower; - printf("fahrenheit\tcelsius\n"); + printf("fahrenheit\tcelsius\n"); - while (fahr <= upper) { - celsius = (5.0 / 9.0) * (fahr - 32.0); - printf("%10.0f\t%7.1f\n", fahr, celsius); - fahr = fahr + step; - } + while (fahr <= upper) { + celsius = (5.0 / 9.0) * (fahr - 32.0); + printf("%10.0f\t%7.1f\n", fahr, celsius); + fahr = fahr + step; + } - return 0; + return 0; } \ No newline at end of file diff --git a/1/4.c b/1/4.c new file mode 100644 index 0000000..3416e02 --- /dev/null +++ b/1/4.c @@ -0,0 +1,21 @@ +#include + +int main(int argc, char *argv[]) { + float celsius, fahr; + int lower, upper, step; + + lower = 0; + upper = 300; + step = 20; + celsius = lower; + + printf("celsius\tfahrenheit\n"); + + while (celsius <= upper) { + fahr = (9.0 * celsius / 5.0) + 32.0; + printf("%7.0f\t%10.1f\n", celsius, fahr); + celsius = celsius + step; + } + + return 0; +} \ No newline at end of file -- cgit v1.2.3