C Temperature Conversion Program Keeps Outputting 0 For Fahrenheit to Celsius [duplicate]

别说谁变了你拦得住时间么 提交于 2019-11-28 14:44:37
cel = (fah-32) * (5/9);

Here, 5/9 is integer division, its result is 0, change it to 5.0/9


And in several lines, you are using

scanf("%f", &*Celsius);

&* is not necessary, simply scanf("%f", Celsius); would do.

cel = (fah-32) * (5/9);

5/9 is int/int and will give you results in int so that is 0.

Change it to

cel = (fah-32) * (5.0/9.0);

or

cel = (fah-32) * ((float)5/(float)9);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!