uninitialized local variable

float celsiusDegrees;
double fahrenheit = (9/5)* celsiusDegrees +32;

i keep getting an error on this
1) You never assign any value to 'celsiusDegrees'. So what number are you converting?

2) (9/5)... both 9 and 5 are integers, so this will evaluate to (1). Which is not what you want. If you want to do floating point division, you'll need to make them floating points: (9.0/5.0)
this program is suppose to have the user enter the number of degrees celsius
What errors are you receiving?
uninitialized local variable on celsiusDegrees
I think you may have looked over Disch's post. You never assign a value to it. If you want to user to enter a value then put cin >> celsiusDegrees; before doing the conversion but don't over look number 2 that Disch mentioned.
what do you mean before doing the conversion? i changed the 9/5 to 9.0/5.0 already
1
2
3
//create Celsius variable
//read into Celsius variable
//convert to Fahrenheit 
isnt celsiusDegrees my variable?
Yes, but you asked what I meant by before the conversion. So you declare the variable, then give it a value, then convert it. I don't know if I can explain it any other way. Other than doing the assignment for you.
Hint: cin >> [insert variable here];
i understand what you mean except for the part where you give the variable a value since the user is suppose to put it

float celsiusDegrees;
double fahrenheit = (9/5)* celsiusDegrees +32;

cout << "What is temperature in celsius";
cin >> celsiusDegrees;
cout << "Conversion to fahrenheit is" << fahrenheit << endl;
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
float celsiusDegrees;
double fahrenheit = (9/5)* celsiusDegrees +32; //WHY DO THE CONVERSION HERE ???

cout << "What is temperature in celsius";

cin >> celsiusDegrees; // AT LAST THE COMPUTER GETS SOMETHING TO WORK ON

// INSERT SOME CODE HERE TO DO THE CONVERSION

cout << "Conversion to fahrenheit is" << fahrenheit << endl; 
so put double fahrenheit = (9/5)* celsiusDegrees +32; where it says // insert some code to do conversion, i tried that and didnt work, i get the same issue
1
2
3
4
5
6
double Celsius;

std::cout << "Please enter degrees(Celsius): ";
std::cin >> Celsius;

double Fahrenheit = Celsius * 9.0 / 5.0 + 32;
closed account (48T7M4Gy)
Time to show us all of the code you are trying to run Latch100.
lmao ^, finally figured it out , it was actually something else i was doing wrong but you guys gave me an idea on how to solve it. thanks
Topic archived. No new replies allowed.