How to remove an error message from a p C++ program

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 ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    2

    How to remove an error message from a p C++ program

    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"
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Oct 2010
    Posts
    2
    Can anyone help me?

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    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
    #1. Try removing the brackets I've highlighted.
    #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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. program to remove comments from source
    By Abda92 in forum C Programming
    Replies: 12
    Last Post: 12-25-2006, 04:18 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21