Why does division result in zero instead of a decimal?

It looks like you have integer division in the second case:

tempC=((5/9)*(tempF-32))

The 5 / 9 will get truncated to zero.

To fix that, you need to make one of them a floating-point type:

tempC=((5./9.)*(tempF-32))

Leave a Comment