I have recently started to program in C++ and i wrote a simple file to try and test. It converts Celsius to Fahrenheit and vice versa. It keeps giving me an error about expecting a 'while', and a '('
As i said I'm new to this and really don't know what to try. I've moved the if else and else onto the same line as the ending curly brace, of the former if/if else statement.
#include <iostream>
int main()
{
int f;
int c;
char choice;
ask:do {
std::cout << "Hello welcome! Would you like to convert from C to F (a) or F to C (b)?\n";
std::cin >> choice;
}
if (choice == "a") { // that if before this comment has squiggly red line
std::cout << "Great, What is the temperature in Celcius? (No decimals please)\n";
std::cin >> c;
f = (c * 1.8) + 32;
std::cout << "The temp in Farenheight is " << f << "degrees\n";
}
if else (choice == "b") {
std::cout << "Great, What is the temperature in Celcius? (No decimals please)\n";
std::cin >> c;
c = (f / 1.8) - 32;
std::cout << "The temp in Celsius is " << c << "degrees\n";
}
else {
std::cout << "Sorry that wasn't an option. Please try again.";
goto ask;
}
} // this also is squiggly
I would like it to output the number of c to f vice versa, but it wont run and it says:
expected a 'while' 18 ,5
expected a '(' 42 ,1