im trying to write a loop which will show when Celsius equals fahrenheit.
The loop counts down from Celsius = 100degrees and the loop stops when the 2 temperature measures are equal.
the formula to convert the 2 is:
fahrenheit = ((9* celsius)/5)+32)
I keep getting following warning in row 9 & 12 (aka 12|warning: 'c' is used uninitialized in this function [-Wuninitialized]
also, the loops continues to run to celsius equals -42 degrees, however it should stop at -40 degrees?
any help would be most appreciated
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main()
{
int c, f;
for(int c(100); f != c ; c--)
{f = ((9* c)/5)+32;
cout << c << "\t" << f << endl;
}
if(f == c)
cout << " f equals c at degree " << c << endl;
return 0;
}
Why are you declaring c in two places? Lines 6 & 8. Declare c in one place and initialize it to 100. As for f, first initialize it to 100 degrees Celsius converted to Fahrenheit (212).