I have an issue with a program I am writing for an assignment, I have been trying to resolve it for the past 2 days. My function keeps returning 0 and I dont know why.
This is my function prototype
This code is from main where I call the functionCode:float farToCel ( int ); //Farhenheit to Celcius function prototype using pass by value
And, here is the function definitionCode:case 2: cout << "Enter the value in Farenheit "; cin >> value; a = farToCel(value); cout << value << " Farenheit is equal to " << a << " Celcius\n" << endl; break;
I have even tried debugging and value is being passed to the function correctly and it still returns a 0 every time. Could someone please let me know what I'm doing wrong here?Code:float farToCel(int value) { float result; result = ((5 / 9) * (value - 32)); return result; }




Reply With Quote