I just started C++ two days ago. I am having a slight problem. When I give the input- 97 Fahrenheit, I get the output as 36 Celsius instead of 36.11, having declared TempC as float type.
#include <iostream>
using namespace std;
main()
{
int TempF;
float TempC;
cout <<"Enter the Temperature in Fahrenheit: ";
cin >> TempF;
TempC = (TempF-32)*5/9;
cout <<"The Temperature on Celcius scale is "<< TempC << endl;
system("pause");
}
it can be either a float or a double. int is a straight integer, and will only be displayed as a integer and the .011 will not be a part, whereas with a float or double the decimal part is included.