版权声明:转载时打个招呼。 https://blog.csdn.net/qq_15971883/article/details/89342314
练习1-4:编写一个程序,打印摄氏温度转换为相应华氏温度的转换表。
#include <stdio.h>
/* 当celsius = 0, 20, 40, ..., 300时,打印摄氏温度与华氏温度对照表*/
int main(void)
{
float fahr, celsius;
int lower = 0;
int upper = 300;
int step = 20;
celsius = lower;
printf("摄氏温度-华氏温度转换表\n");
while (celsius <= upper)
{
fahr = (9.0 * celsius) / 5.0 + 32.0;
printf("%3.0f %6.1f\n", celsius, fahr);
celsius += step;
}
system("pause");
return 0;
}