相关疑难解决方法(0)

将华氏温度转换为摄氏温度的C程序始终打印为零

我需要一些帮助,用于将华氏温度转换为C摄氏温度的程序.我的代码看起来像这样

#include <stdio.h>
int main(void)
{
    int fahrenheit;
    double celsius;

    printf("Enter the temperature in degrees fahrenheit:\n\n\n\n");
    scanf("%d", &fahrenheit);
    celsius = (5 / 9) * (fahrenheit - 32);
    printf("The converted temperature is %lf\n", celsius);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

每次执行它时,结果为0.000000.我知道我错过了什么,但无法弄清楚是什么.

c

8
推荐指数
2
解决办法
9万
查看次数

标签 统计

c ×1