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"
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.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens