I need some help with a program for converting Fahrenheit to Celsius in C. My code looks like this
#include int main(void) { int fahrenhe
try celsius = ((double)5/9) * (fahrenheit-32); Or you can use 5.0.
celsius = ((double)5/9) * (fahrenheit-32);
The fact is that "/" looks at the operand type. In case of int the result is also an int, so you have 0. When 5 is treated as double, then the division will be executed correctly.