i ma doing functions to convert Fahrenheit temperature
Celsius and i am getting a zero why? this is my code:
#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::fixed;
//function prototypes
double getFahrenheit();
int getCelcius(double);
int main()
{
//declare varibles
int celcius = 0;
double fahrenheit = 0;
//functions calls
fahrenheit = getFahrenheit();
celcius = getCelcius(fahrenheit);
cout %26lt;%26lt; fixed %26lt;%26lt; setprecision(0);
cout %26lt;%26lt; "Celsius temperature is: " %26lt;%26lt; celcius %26lt;%26lt; endl;
return 0;
} //end of main function
//*****function definitions*****
double getFahrenheit()
{
double fahrenheit = 0.0;
cout %26lt;%26lt; "Enter fahrenheit: " %26lt;%26lt; endl;
cin %26gt;%26gt; fahrenheit;
return fahrenheit;
}
//*****function definitions*****
int getCelcius(double fahrenheit)
{
int output = 0;
output = 5.0/9.0 * (fahrenheit - 32.0);
return output;
}
Why my ouptput in my C++ program is not right? help me please!!!?
I compiled it and it worked for me... You may consider doing this though:
change int getCelcius to double getCelcius
Reply:You have an integer function, not a floating point one.
chelsea flower show
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment