Code:
// This program converts Celcius to Fahrenheit
#include <iostream.h>
#include <iomanip.h>
void main(void)
{
float Celcius, Fahrenheit;
cout << "Please enter a a temperature in Celcius: ";
cin >> Celcius;
Fahrenheit = ((9.0/5.0)*Celcius) + 32;
cout.setf(ios::fixed);
cout.precision(1);
cout << endl;
cout << "The temperature you entered is " << Fahrenheit << " degrees Fahrenheit." << endl << endl;
}
Note the Fahrenheit calculation. If I use the following, it simply doesn't work:
Fahrenheit = ((9/5)*Celcius) + 32;
It's taking the 9/5 and converting it to an integer value of 1. I had to use the decimal to get it to work. Is this a feature of my compiler? - Visual C++ 6.0
Why would it do this?