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"
This is a discussion on How to remove an error message from a p C++ program within the C++ Programming forums, part of the General Programming Boards category; I am trying to debug a program and it keeps giving my a couple of error messages and I cannot ...
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.
I used to be an adventurer like you... then I took an arrow to the knee.