### problem with variables/converting fahrenheit to centigrade

Ok. So, I have just started up my intro to programming class and am already confused. For this project we are supposed to be converting temperature from fahrenheit to centigrade. Now, my instructor has already given me this sample code to work with.

Sample Code

The code snippet below converts a temperature inputted in Fahrenheit to Centigrade.

//Declare variables for keeping temperature in Fahrenheit and Centigrade

double f, c;

//Input temperature in Fahrenheit as a String

cout << “Enter temperature in Fahrenheit: “ << endl;

cin >> f;

//Convert Fahrenheit temperature in Centigrade

c = (5.0 / 9.0) * (f – 32.0);

That is the sample code above. Here is what I inputted.

#include <iostream>

using namespace std;

int main()
{

//Declare variables for keeping temperature in Fahrenheit and Centigrade

double f,c;

//Input temperature in Fahrenheit as a String

cout << "Enter temperature in fahrenheit: " <<endl;
cin >> f;

c = (5.0 / 9.0)*(f – 32.0);

cout << "The conversion of fahrenheit to centigrade: " << c << endl;

return 0;
}

And I get an error code with the compiler on line 24. I don't understand what's wrong here. Am I supposed to declare another variable? Thank you. I'm already seriously behind and Computer Science is my major!!!!
Which line is 24? And what does the error say?
Also, when asking for the temperature. You can take out that endl. That way the value will be entered in after the colon. I think it looks better that way.
What character did you use for a minus sign in the following line?
 `` `` ``c = (5.0 / 9.0)*(f - 32.0);``

I retyped the minus sign and it compiled fine.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
line 24 is c = (5.0 / 9.0)*(f – 32.0);

error: stray '\226' in program
In function 'int main()':
error: expected ')' before numeric constant
=== Build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===
Oh yeah, for some reason the - sign never took. So I did retype it and it worked fine. Thank you AbstractionAnon. This is all new to me, including this forum. lol.
Topic archived. No new replies allowed.