码迷,mamicode.com
首页 > 其他好文 > 详细

C - The C Answer (2nd Edition) - Exercise 1-5

时间:2015-07-11 20:16:44      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:exercise 1-5

/*
Modify the temperature conversion program to print the table in reverse order, 
that is, from 300 degrees to 0.
*/

#include <stdio.h>

/* print Fahrenheit-Celsius table in reverse order */
main()
{
    int fahr;
    
    for(fahr = 300; fahr >= 0; fahr -= 20)
    {
    	printf("%3d %6.1f\n", fahr, (5.0 / 9.0) * (fahr - 32));
    }
}

/* Output:

300  148.9
280  137.8
260  126.7
240  115.6
220  104.4
200   93.3
180   82.2
160   71.1
140   60.0
120   48.9
100   37.8
 80   26.7
 60   15.6
 40    4.4
 20   -6.7
  0  -17.8
Press any key to continue . . .

*/

版权声明:本文为博主原创文章,未经博主允许不得转载。

C - The C Answer (2nd Edition) - Exercise 1-5

标签:exercise 1-5

原文地址:http://blog.csdn.net/troubleshooter/article/details/46843769

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!