CSM217: C for Computer Scientists
Lecture 1: Exercise 4: Celsius Conversion Program with heading
#include
/* print Fahrenheit-Celsius table
for fahr = 0, 20, ..., 300 */
main() {
int fahr, celsius;
int lower, upper, step;
lower = 0; /* lower limit of fahr */
upper = 300; /* upper limit of fahr */
step = 20;
fahr = lower;
printf("Fahrenheit\tCelcius\n");
while (fahr <= upper) {
celsius = 5 * (fahr - 32) / 9;
printf("%d\t\t%d\n", fahr, celsius); /* An extra tab has been added! */
fahr = fahr + step;
}
}