"Expression result unused" Help?!

Discussion in 'Mac Programming' started by raaron1990, Oct 1, 2012.

  1. raaron1990, Oct 1, 2012
    Last edited by a moderator: Oct 1, 2012

    raaron1990 macrumors newbie

    Oct 1, 2012
    Los Angeles, CA
    Hi all,

    Hopefully someone can help me out. I'm new to programming, and for class, we have to make a program that determines the day of the week of a specific date that the user enters. I keep getting an error "expression result unused" and I can't figure out why. Here's part of my source code:

    int month, day, years, LTYear, total, Gtotal;
        cout<<"Input date in M/DD/YYYY format. (ex. 2/07/1990 or 10/13/2010)"<<endl;
        cin>>month; day; years;
        if (month==2 && years%4==0 && years%100!=0 && day>=30)
            cout<<"Invalid day.\n";
        else if (month==2 && day>=29)
            cout<<"Invalid day.\n";
        if (day<=1||day>31)
            cout<<"Invalid day.\n";
        if (years<1900 || years>2099)
            cout<<"Invalid year.\n";
    I get the issue when I try to get the cin for day and year. Any advice?

    Thanks in advance!
  2. knightlie, Oct 1, 2012
    Last edited: Oct 2, 2012

    knightlie macrumors 6502a

    Feb 18, 2008
    I'm not a C programmer, but this:
    cin>>day; month; year;
    looks wrong to me - that appears to be three statements:
    A semi-colon marks the end of a statement. The compiler is complaining that the month; and year; statements do not do anything. Maybe it should be:
    cin>>day, month, year;
    Edit: Yes, the cin line is incorrect. As this is for class I won't give you the answer ( ;) ), but you need to change that line to be able to populate multiple variables.
  3. gnasher729 macrumors G5


    Nov 25, 2005

Share This Page