What is wrong with the code? The code was for conversion from Celsius to Fahrenheit
degF =5/9*(degC+32)
degF = (9/5)*degC + 32;
or
degC = (5/9)*(degF-32)
degF =5/9*(degC+32)
In the above statement 5 and 9 are integer so, so it is doing the integer division,
so you may end the with the result 5/9 =0. So whole result is 0
Solution is convert any number to float
degF =5.0/9*(degC+32) or degF =5/9.0*(degC+32)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks