diff --git a/02-vars-and-math.c b/02-vars-and-math.c index 2a881f6..16df37f 100644 --- a/02-vars-and-math.c +++ b/02-vars-and-math.c @@ -1,11 +1,15 @@ #include +#define LOWER 0 +#define UPPER 300 +#define STEP 20 + /* print Fahrenheit-Celsius table */ int main() { int fahr; printf("Fahrenheit\tCelsius\n=======================\n"); - for (fahr = 300; fahr >= 0; fahr = fahr - 20) + for (fahr = UPPER; fahr >= LOWER; fahr = fahr - STEP) printf("%3d\t\t%7.1f\n", fahr, (5.0/9.0)*(fahr-32)); } diff --git a/03-celsius-to-fahrenheit.c b/03-celsius-to-fahrenheit.c index 85e9b7a..96c2164 100644 --- a/03-celsius-to-fahrenheit.c +++ b/03-celsius-to-fahrenheit.c @@ -1,11 +1,15 @@ #include +#define LOWER 0 +#define UPPER 300 +#define STEP 20 + /* print Celsius-Fahrenheit table */ int main() { int cels; printf("Celsius\t\tFahrenheit\n==========================\n"); - for (cels = 0; cels <= 300; cels = cels + 20) + for (cels = LOWER; cels <= UPPER; cels = cels + STEP) printf("%3d\t\t%10.0f\n", cels, (9.0/5.0)*cels+32); }