28 lines
No EOL
509 B
C
28 lines
No EOL
509 B
C
/*
|
|
K&R C 2nd Edition, exercise 1-4
|
|
Convert Celsius temperatures to Fahrenheit (floating point)
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
float fahr, celsius;
|
|
float upper, lower, step;
|
|
|
|
upper = 200;
|
|
lower = 0;
|
|
step = 10;
|
|
|
|
celsius = lower;
|
|
|
|
printf("Celsius to Fahrenheit conversion table\n\n");
|
|
|
|
while (celsius <= upper) {
|
|
fahr = celsius * (9.0/5.0) + 32.0;
|
|
printf("%6.0f %6.2f\n", celsius, fahr);
|
|
celsius = celsius + step;
|
|
}
|
|
|
|
return 0;
|
|
|
|
} |