人間夜行

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

K&R C Bible Exercises 1-4

| 评论

Write a program to print the corresponding Celsius to Fahrenheit table.

Example:

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

评论