Ok i'm using Borland CBX and Windows XP. My program is to convert farenheit to celsius. I got the code off the CD that came with "Sams Teach Yourself C++ in 24 Hours" so i doubt the code is wrong. I can run it fine in the IDE but i can run the .exe in Windows XP but when i type in the temperature, say 120 and then press enter it closes the window(it opens by default in the commandline)
I know that its not the program because I have tried others and they don't work either.
This is my source code
I know that its not the program because I have tried others and they don't work either.
This is my source code
#include <iostream>
float Convert(float);
int main()
{
float TempFer;
float TempCel;
std::cout << "Please enter the temperature in Fahrenheit: ";
std::cin >> TempFer;
TempCel = Convert(TempFer );
std::cout << "\nHere's the temperature in Celsius: ";
std::cout << TempCel << std::endl;
return 0;
}
float Convert(float TempFer)
{
float TempCel;
TempCel = ((TempFer - 32) * 5) / 9;
return TempCel;
}
float Convert(float);
int main()
{
float TempFer;
float TempCel;
std::cout << "Please enter the temperature in Fahrenheit: ";
std::cin >> TempFer;
TempCel = Convert(TempFer );
std::cout << "\nHere's the temperature in Celsius: ";
std::cout << TempCel << std::endl;
return 0;
}
float Convert(float TempFer)
{
float TempCel;
TempCel = ((TempFer - 32) * 5) / 9;
return TempCel;
}
Comment