I'm building a fraction calculator in C++ & I've ran into the error: "expected ';' before string constant" & I can't figure out whats wrong with it. Here is my code:
_______________________________________________________________________________
int FracPer () {
cout << "You have entered reading fractions & their percentage!" << endl;
cout << "Please enter the numerator: " << endl;
cin >> numer1;
cout << "Please enter the denominator you want to place under " << numer1 << ": ";
cin >> denom1;
frac1 = numer1 "/" denom1;
percent = (numer1 / denom1) * 100;
cout << "The whole fraction you have entered is " << frac1 << " & its percentage is " << percent << ".";
cout << endl << endl;
}
_______________________________________________________________________________
The error is in the line frac1 = numer1 "/" denom1;. Please help me if you can!
Considering what the OP is doing on the next line, it seems like numer1 and denom1 are numerical values...? So if that's right, just remove the quotes around the / and possibly make sure you doing floating point division if that's what you want.
For this to work, you will need to make a cast from a string type (like std::string) to an integral type, or vice-versa. C++ won't implicitly convert between them.