summaryrefslogtreecommitdiff
path: root/one/temp.c
blob: 3b49c39ae71ecf991219403d94d4b85dad85e93d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>

#define LOWER 0
#define UPPER 300
#define STEP 20

int
main()
{
	float fahr, cel;

	printf("Fahrenheit-Celsius table\n");
	for (fahr = UPPER; fahr >= LOWER; fahr -= STEP) {
		cel = (5.0 / 9.0) * (fahr - 32.0);
		/* 3 and 6 digits wide with 0 and 1 digits after the dot */
		printf("%3.0f %6.1f\n", fahr, cel);
	}

	printf("\nCelsius-Fahrenheit table\n");
	for (cel = LOWER; cel <= UPPER; cel += STEP) {
		fahr = 9.0 / 5.0 * cel + 32.0;
		printf("%3.0f %6.0f\n", cel, fahr);
	}
	return 0;
}