### Input Celsius and convert it to Farenheit

hey guys, Im new to C++. I've tried to solve the problem but no luck. My code will be shown below. Please advice me where I went wrong. Thanks

Write a program that reads a Celsius degree in double, converts it to Farenheit, and displays the result. The formula for conversion is: farenheit = (9/5) * Celsius + 32;
(Note: 9/5 is 1 in C++, so you need to use 9.0/5)

#include <iostream>
using namespace std;

int main()
{
double C, F;

cout << "Welcome";
cout << "Enter the temperature in Celsius to convert it to Fahrenheit";
cin >> C
F = (9.0/5)*(C + 32);
system("pause");
return 0;

}
Missing semi-colon at `cin >> C`. And if you want to display the result in your screen you need to cout it.
For future reference, it always help when your provide a description of your problem.
In your case, the program will not compile because you are missing a ";"

See if you can find out where it is missing.
Wow, I totally missed the semi colon ¬¬ thanks guys !
Thanks, Locien how would I counter that?
Last edited on
I said cout it, as in `cout << something`. ;)
Ah right, I think I need to head to sleep after this because I saw 'count' ><
#include <iostream>
using namespace std;

int main()
{
double C, F;

cout << "Welcome \n";
cout << "Enter the temperature in Celsius to convert it to Fahrenheit";
cin >> C;
F = (9.0 / 5)*(C + 32);
cout << F;
system("pause");
return 0;
}
Got it working I think. How do I get the answer to be displayed away from the 'Press any key to continue'...

i.e.

Welcome
Enter the temperature in Celsius to convert it to Fahrenheit 10
75.6Press any key to continue...
Last edited on
Next time place your code in [ code] blocks.

And this should make your answer show up on its own line.
`cout << F << endl;`
Topic archived. No new replies allowed.