....

2014年5月13日 星期二

[長知識] C語言 - 新手篇章 - 華氏溫度轉攝氏溫度

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

//華氏溫度
int Fah;
        //攝氏溫度
float Cel;


printf("input Fah:");

scanf("%i", &Fah);

//C++內的5.0是指5.0d,C內的5.0指5.0f
Cel = (Fah - 32)*(5.0f / 9);

printf("Cel is %.2f ", Cel);

return 0;
}

沒有留言:

張貼留言