《C程序设计语言》练习1-5

 1 #include<stdio.h>
 2 /*修改温度转换程序,要求以逆序(即按照从300度到0度的顺序)打印温度转换表*/
 3 main ()
 4 {
 5   float fahr,celsius;
 6   int lower,upper,step;
 7   lower=0;/*温度表的下限*/
 8   upper=300;/*温度表的上限*/
 9   step=20;/*步长*/
10   printf("华氏温度与摄氏温度对照表\n");/*标题*/
11   for (fahr=upper;lower<=fahr;fahr=fahr-step)
12     {
13       celsius=(5.0/9.0)*(fahr-32);/*注意*号不要忘了写*/
14       printf("%3.0f %6.1f\n",fahr,celsius);
15     } 
16 }

 

posted @ 2013-08-18 09:35  叶卢庆  阅读(175)  评论(0编辑  收藏  举报