mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Don't bury magic numbers!
This commit is contained in:
parent
f88aa3d25f
commit
fe248c5a30
@ -1,11 +1,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define LOWER 0
|
||||||
|
#define UPPER 300
|
||||||
|
#define STEP 20
|
||||||
|
|
||||||
/* print Fahrenheit-Celsius table */
|
/* print Fahrenheit-Celsius table */
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int fahr;
|
int fahr;
|
||||||
|
|
||||||
printf("Fahrenheit\tCelsius\n=======================\n");
|
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));
|
printf("%3d\t\t%7.1f\n", fahr, (5.0/9.0)*(fahr-32));
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define LOWER 0
|
||||||
|
#define UPPER 300
|
||||||
|
#define STEP 20
|
||||||
|
|
||||||
/* print Celsius-Fahrenheit table */
|
/* print Celsius-Fahrenheit table */
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int cels;
|
int cels;
|
||||||
|
|
||||||
printf("Celsius\t\tFahrenheit\n==========================\n");
|
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);
|
printf("%3d\t\t%10.0f\n", cels, (9.0/5.0)*cels+32);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user