练习1-4 编写一个程序打印摄氏温度转换为响应华氏温度的转换表。
#include <stdio.h>int main(int argc, char *argv[]) {
(void) argc;
(void) argv;
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
fahr = lower;
while (celsius <= upper) {
fahr = celsius * 9.0 / 5.0 + 32.0;
printf("%3.0f %6.1f\n", celsius, fahr);
celsius += step;
}
return 0;
}
运行结果:
标签:练习题,upper,lower,fahr,int,step,celsius,程序设计,新版 From: https://www.cnblogs.com/gongwenjun/p/18377734