Hello,
I created a program to convert Celsius to Fahrenheit.
But it needs to round up or down. Meaning 55 F need to be 13 Celsius and not 12.7... I read now that I need to change it to int..which I did right hereCode:#include <iostream> using namespace std; float Fahrenheit, Celsius; int main() { float Fahrenheit; float Celsius; cout<<"Enter the temperature in Fahrenheit: "; cin>>Fahrenheit; Celsius=(Fahrenheit-32)*5/9; cout<<"The temperature in Celsius is: "<<Celsius; cout << (int)Celsius << endl; system ("pause"); return 0; }
Also I need to do it by adding 0.5 to the calculation expression. Well that's itCode:cout<<"The temperature in Celsius is: "<<Celsius; cout << (int)Celsius << endl; system ("pause");
but of course it wont work, if I do add + 0.5 to it. Can someone help me with this?Code:Celsius=(Fahrenheit-32)*5/9;



LinkBack URL
About LinkBacks




