Following code is producing dozens of C2784 errors and I would like advice on why? I have int as "choice" as I tried Char with C or F to be input and I wondered if that might be contributing. I am sure its something simple - all help received gratefully! (Commented out text does work!)
#include <iostream>
#include <math.h>
usingnamespace std;
int main ()
{
int c, f;
int choice;
int result;
/*cout << "Enter a value in Fahrenheit you wish to convert to Celsius" << endl;
cin >> f;
c = 5 * (f-32) / 9;
cout << "You entered " << f << " which is " << c << " in degrees celsius." << endl;
return 0;*/
cout << "Enter 1 for C or 2 for F for the temperature you are going to input" << endl;
cin >> choice;
if (choice == 1) {
cout << "Enter the value for Celsius you want to be converted to Fahrenheit" << endl;
cin >> c;
f = (9 * c)/5 + 32;
result = f;
cout >> c >> " in degrees fahrenheit is " >> result >> endl;
}
if (choice == 2)
{
cout << "Enter the value for Fahrenheit you want to be converted to Celsius" << endl;
cin >> f;
c = 5 * (f-32) / 9;
result = f;
cout >> f >> " in degrees celsius is " >> result >> endl;
}
else {cout >> "That is not a C or F" >> endl;
}
return 0;
}