F = (C * 9/5 ) + 32 and F = (9/5 * C) + 32 yield two different results although the input for C is the same. I realize that there is some kind of precedence in operators but i am not sure about it. Does multiplication come before division ?
An input of 20 gives the Fahrenheit value as 68(correct one) in the first case and 52 in the second.
#include<stdio.h>
int main()
{
float cel , fahr ;
printf("Enter the temperature(C): ");
scanf("%f",&cel);
fahr = (9/5 * celt is ) + 32;
printf("\nThe temperature in fahranheit is %f ",fahr);
}
Expected result is 68 but its 52 for the above code. If I switch the position of '9/5' and 'cel' it gives the correct result. Why is that ?