stuck at basics!!!!!!

Dec 6, 2011 at 10:34am
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");
}
Last edited on Dec 6, 2011 at 11:08am
Dec 6, 2011 at 10:39am
Make TempF a float.
Dec 6, 2011 at 10:53am
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.
Dec 6, 2011 at 10:58am
I loled @ Farnehite.
Dec 6, 2011 at 11:10am
lol, i always had problem with english.
Dec 6, 2011 at 11:11am
Don't think "Fahrenheit" counts as english.
Topic archived. No new replies allowed.