I have been working on this code for hours every day for the last week and I just cannot seem to get it. I do not even know if I am starting it correctly. The program takes no input from a user. It needs to be able to find the value where Fahrenheit is equal to Celsius using (Fahrenheit = 9 / 5 * Celsius + 32). It is supposed to initialize Celsius as 100 and decrement the value in a loop. If anyone could help explain loops to me and how to set them up in this situation, it would be a tremendous help!
The best loop to use in your case would be a for loop.
1 2 3 4 5 6 7 8 9 10
for(int celsius = 100; ; celsius--) //initialize celsius to 100, decrement celsius every loop (we want the loop to continue until the answer is found, so we leave the condition out)
{
float fahrenheit = (celsius + 32) * (9.0 / 5.0); //convert celsius to fahrenheit
if(fahrenheit == celsius) //check if they are equal
{
cout << "fahrenheit is equal to celsius when celsius is " << celsius << endl; //output answer
break; //leave for loop
}
}
This should do what you want, but it is important that you understand it. If you don't understand any part of it, look it up or just ask.