summaryrefslogtreecommitdiff
path: root/ch01/ex04-temp.c
blob: f78a19130bc6fc3d23b430be26b7ff4958ea9b2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>

/* print Celsius-Fahrenheit table */
int main()
{
	float celsius, fahr;
	int lower, upper, step;

	lower = 0;
	upper = 300;
	step = 20;

	printf("%3s %6s\n", "C", "F");

	celsius = lower;
	while (celsius <= upper) {
		fahr = celsius / (5.0/9.0) + 32.0;
		printf("%3.0f %6.0f\n", celsius, fahr);
		celsius = celsius + step;
	}
}