[Solved] c language temperature converter : fahrenheit to celcius [closed]


Doing this:

celcius=(ferenheit-32)*(5.0/9.0);

Does not mean that the value of celcius will always be (ferenheit-32)*(5.0/9.0), anytime that ferenheit changes. What is does mean is that it sets celcius to (ferenheit-32)*(5.0/9.0) at the time the statement is encountered. Since ferenheit doesn’t have value yet when this statement runs, the value of celcius is indeterminate.

You need to first read in the value of ferenheit, then calculate celcius based on that:

printf("Enter your ferenheit temperature : ");
scanf("%f",&ferenheit);             // first read
celcius=(ferenheit-32)*(5.0/9.0);   // then calculate
printf("Your ferenheit temperature in celcius is :%d\n",celcius);

Also, they’re spelled “celsius” and “fahrenheit”.

solved c language temperature converter : fahrenheit to celcius [closed]