Why do I get expected a ')' before the 'y' in if (compare = 'Y' || compare 'y')

How do I fix the error I get?

This is only a section of my code the entire code is 400 plus lines. If need be I will post the entire code.

void differenceCalculator()
{ int choice, compare;
const int min = 1, max = 2;

cout << "Would you like to verify or validate the 15 or 30 year amortization table? Enter 'Y' or 'N' \n";
if (compare = 'Y' || compare 'y')
{
cout << "1. 15 year amortization table. \n";
cout << "2. 30 year amortization table. \n";

cout << "Please select from one of the options above: ";
cin >> choice;
while (choice < min || choice > max)
{
cout << "The only valid choices are " << min << " to " << max << ". Please re-enter. " << endl;
cin >> choice;
}
}
else
cout << "Returning to main menu. \n";

cout << endl;

}
Incorrect syntax. First, you meant ==, not =.
== tests for equality, = is an assignment.
Second, there's no operator between "compare" and 'y'.

Change to:
if (compare == 'Y' || compare == 'y')
First it would help if you use code tags.

Try to correct the code first and see if the problem still exist.
int choice, compare;

'Y' or 'y' is not an INT.

Line 6: There is no cin of compare.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.