# Converting fahrenheit to celsius but getting 0.00 output

This is a discussion on Converting fahrenheit to celsius but getting 0.00 output within the C Programming forums, part of the General Programming Boards category; For some reason when I input a number in, it comes out 0.00. What did I do wrong? Do I ...

1. ## Converting fahrenheit to celsius but getting 0.00 output

For some reason when I input a number in, it comes out 0.00. What did I do wrong? Do I need to int Fahrenheit?

Code:
```/* Directives */

#include <stdio.h>
#include <math.h>

int main(void)

{

float fahrenheit, T;

printf("Enter a temperature in Fahrenheit: ");
scanf("%f", &fahrenheit);
T = (5/9) * (fahrenheit - 32);
printf("Celsius is %.2f \n", T);

/* End Program */
return(0);

}```

2. Code:
`T = (5/9) * (fahrenheit - 32);`
In the red bit you are doing integer maths so the result is 0. As you cant have integer units between 1 and 0 so it rounds down.

Try:
Code:
`T = (5.0f/9.0f) * (fahrenheit - 32.0f);`

3. Although, you only need one of them to be a float to get a proper result.

4. Ah, no wonder. Thanks so much.

How would I define m/s to ft/s as a constant?

I'm supposed to use 4 significant digits for your conversion factor between m/s to ft/s (which should be defined as a
constant). How would I do this?

My program is outputting 123.45 m/s, but I also need it to say next to the 123.45 m/s, or 405.09 ft/s.

ex: Speed is: 123.45 m/s, or 405.09 ft/s.

5. How do you convert m/s to ft/s?

6. To go from meters to feet, times meter by 3.28084. But I was wondering if there was a way to make this a constant cause the hw prompt says it should be a constant. Like #define meter to feet 3.28084?

7. If you want. Macro names can't have spaces in them, though.

8. Ok, so I just put in #define tofeet 3.28084 for the constant and use the word tofeet in my equation.

9. Thanks for the help!!!