31 lines
610 B
C
31 lines
610 B
C
#include <stdio.h>
|
|
#define LOWER 0
|
|
#define UPPER 300
|
|
#define STEP 20
|
|
|
|
int main() {
|
|
float fahr, celsius;
|
|
int lower, upper, step;
|
|
|
|
fahr = LOWER;
|
|
printf("Temperature conversion\n");
|
|
while (fahr <= UPPER) {
|
|
celsius = (5.0 / 9.0) * (fahr - 32.0);
|
|
printf("%3.0f\t%6.1f\n", fahr, celsius);
|
|
fahr = fahr + STEP;
|
|
}
|
|
|
|
printf("\nNow Celcius -> Fahr table\n");
|
|
lower = 0;
|
|
upper = 100;
|
|
step = 5;
|
|
fahr = 0.0;
|
|
celsius = lower;
|
|
while (celsius <= upper) {
|
|
fahr = (celsius * (9.0 / 5.0)) + 32;
|
|
printf("%3.0f\t%6.1f\n", celsius, fahr);
|
|
celsius = celsius + step;
|
|
}
|
|
|
|
return 0;
|
|
}
|