I have a problem
I have to convert temperature between farenhiet and celsius.
here is my code
my problem is that i get the wrong results. When i enter 5 i should be getting -15.0 but instead i get 1120.0. Can someone help me.
int main ()
printf("Please enter a fahrenheit temperature ");
check = scanf("%f", &temp);
if (check != 1)
temp = (temp - 32.0) * 5.0 / 9.0;
printf("\nTemperature converted to celsius = %.1f\n", temp);
i found why the result stuffed up, i had to change the double to a float. Can any one tell me the difference between double and float? I always thought they were the same thing
float celcius, farenheit;
printf("Enter temp in Farenheit: ");
celcius = (farenheit - 32) * 5/9;
printf("Celcius: %f\n", celcius);
> Can any one tell me the difference between double and float?
Well it's important in the scanf
scanf( "%f", &float_var );
scanf( "%lf", &double_var );
doubles typically take up twice as much memory as floats, but they are a lot more precise, and have a greater range than floats.