25 lines
492 B
C
25 lines
492 B
C
/*
|
|
* Print a table of Fahrenheit temperatures and their Celsius equivalents.
|
|
* From K&R 2nd ed., 1-2
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
int main (void) {
|
|
int fahr, celsius;
|
|
int lower, upper, step;
|
|
|
|
lower = 0; // Lower limit of temperature scale
|
|
upper = 300; // Upper limit of temperature scale
|
|
step = 20; // Step size
|
|
|
|
fahr = lower;
|
|
while (fahr <= upper) {
|
|
celsius = 5 * (fahr-32) / 9;
|
|
printf("%3d %7d\n", fahr, celsius);
|
|
fahr = fahr + step;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|