人間夜行

一切の有為の法 夢幻泡影の如し

K&R C Bible Exercises 1-3

| 评论

Modify the temperature conversion program to print a heading above the table.

Example:

#include <stdio.h>
/* print Fahrenheit-Celsius table */
int main()
{
	float fah,cel,upper;
	int step;
	step=10;
	fah=0;
	upper=120;
	printf("Fahrenheit-Celsius Table\n");
	printf("%6s %6s\n","F","C");
	printf("---------------\n");
	while(fah<=upper)
	{
		cel=(fah-32)*5.0/9.0;
		printf("%6.0f %6.1f\n",fah,cel);
		fah+=step;
	}
	return 0;
}
 

评论