I need a program that finds the temperature that is the same in both Celsius and Fahrenheit. The formula to convert from Celsius to Fahrenheit is :
F = ((9 x C) / 5 )+ 32
Initialize the temperature to 100 degrees C. In a loop, decrement the Celsius value and compute the corresponding temperature in Fahrenheit until the two values are the same.
The formula may not give an exact result for every Celsius because you are working with integers.
It has to have a loop watchdog timer. Using a ‘const’ declaration for your maximum loop counter
This is what I got so far & no idea how to continue:
//make Celcius (cels) & Farentheight (fahr) degree until they equal
//each other programs & must stop when both are equal...loop it while
//they are not equal.
#include <iostream>
using namespace std;
int main()
{
int lcv = 0;
int cels = 100;
int fahr;
Sorry rapdudty. I thought Denis had reposted your code with code tags but it's different.
So, of course, you have different problems starting with the fact that fahr is not initialized to anything before your while loop starts.
Also, don't forget to increment your lcv in the loop or it doesn't do anything. AND, be careful when you check it for a 'bad loop'. = and == are NOT the same!
Again, put a statement like 'cout<< cels << " " << fahr << endl;' inside your loop to probe the values on each iteration. It helps expose problems when a loop is giving you unexpected behavior.
It's -40, by the way. Now you can verify whether your program is correct.
EDIT: Oh, and one more thing, just in case you want to do it the smart way. For
f(x)=a*x+b
g(x)=c*x+d
The intersection of f(x) and g(x) is (d-b)/(c-a). Obviously, if c==a, there is no intersection.
By the way,your code looks shitty .Use the "code" and "/code"(both in [] ) commands before and after the code - it will look more readable.And why don`t you try to do it with doubles ?It will be more accurate-when you do something , do it correctly.