# Function help

• 12-02-2007
Micolejr2
Function help
My output for the variable celsius is 0 everytime. I can't figure it out =(. Can anyone spot what is wrong?

Code:

```#include <iostream> using namespace std; double get_celsius(double); int main() {         double fahrenheit, celsius;         cout << "This progam converts fahrenheit to celsius.\nPlease input a fahrenheit temperature...\n";                 cin >> fahrenheit;         celsius = get_celsius(fahrenheit);         cout << fahrenheit << " fahrenheit is " << celsius << " celsius.\n";         return 0; } double get_celsius(double fahrenheit) {         return (5/9)*(fahrenheit-32); }```
• 12-02-2007
laserlight
Hint: with integer division, 5/9=0
• 12-02-2007
Micolejr2
Ok, i just put .5555 instead of 5/9, how would you code 5/9 to work?

Code:

```double get_celsius(double fahrenheit) {   double x = 5/9,               result;       result = (fahrenheit - 32) * x;     return result;```
would that work?
• 12-02-2007
laserlight
Quote:

how would you code 5/9 to work?
An easy way is to write 5.0/9.0 instead.
• 12-03-2007
Elysia
Hint:
5 == treated as an integer
5.0 == treated as a double
5.0f == treated as a float