shithub: c-2nd-ed

ref: fa760fc4c5c448f078a428f7638b1a5e6637ade2
dir: /1.3.c/

View raw version
// print a fahrenheit -> celsius table
// for fahr = 0, 20, ..., 300
// floating point version
// modified to include a header above the table

#include <u.h>
#include <libc.h>

void
main()
{
	float fahr, celsius;
	int lower, upper, step;

	lower = 0;		// lower limit of table
	upper = 300;		// upper limit
	step = 20;		// step size

	fahr = lower;

	print(" F ->  C\n");		// table header
	print("----------\n");

	while(fahr <= upper){
		celsius = (5.0 / 9.0) * (fahr - 32.0);
		print("%3.0f %6.1f\n", fahr, celsius);
		fahr = fahr + step;
	}

	exits(nil);
}