I am trying to debug a program and it keeps giving my a couple of error messages and I cannot figure out how to fix them. The error messages are expected primary-expression before "else" , expected `;' before "else"
Printable View
I am trying to debug a program and it keeps giving my a couple of error messages and I cannot figure out how to fix them. The error messages are expected primary-expression before "else" , expected `;' before "else"
Can anyone help me?
#1. Try removing the brackets I've highlighted.Code:if (code = 1)
{
cout << "$45,000" << endl;
else if (code == 2 && code == 5)
cout << "$33,000" << endl;
else if (code == 3 || code == 4)
cout << "$25,000" << endl;
else
cout << "Entry error" << endl;
} //end ifs
#2. Change that = to an ==.
#3. That && needs to be a ||... a variable will never be both 2 and 5 at the same time.