打印摄氏度与华氏温度转换表

#include <stdio.h>
/* 当fahr=0,20,...,300时,分别
  打印华氏温度与摄氏温度表 */
main ()
{
        printf("打印温度转换表\n");
        float fahr,celsius;
        float lower,upper,step;

        lower = -17;    /* 温度表的下限 */
        upper = 148;    /* 温度表的上限 */
        step = 11;      /* 步长 */

        celsius = lower;
        while (celsius <= upper){
                fahr = ((celsius * (9.0/5.0)) + 32.0);
                printf ("%3.0f\t%6.1f\n",celsius,fahr);
                celsius = celsius + step;
        }
}

#shell
gcc tempture2.c
./a.out
此条目发表在C分类目录。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Protected with IP Blacklist CloudIP Blacklist Cloud