Thread: new to c++ need help

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    2

    new to c++ need help

    HI All

    I have just started to learn c++ from the tutorials on this website and have got a problem with the following code it carry's on returning the error EXPECTED PRIMARY FUNCTION BEFORE ELSE please help!

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
        cout<<"WHAT IS YOUR AGE ? ";
        int age;
        cin>>age;
        cin.get();
        cout<<"\nWHAT IS YOUR WIFE'S AGE ? ";
        int age2;
        cin>>age2;
        cin.get();
        
        if (age+age2>50);
        {
        cout<<"\nYOUR COMBINED AGE IS GREATER THEN 50";
        cin.get();
        }
        
        else
        
        {
            cout<<"\n YOUR COMBINED AGE IS LESS THEN 50 ";
            cin.get();
        }
            
    
        }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Code:
    if (age+age2>50);
    Oops. As tempting as it is to have something where you would expect "then", you have to leave that spot completely blank.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    2
    Your a lifesaver tabstop thanks alot man

  4. #4
    Registered User
    Join Date
    Aug 2009
    Location
    China
    Posts
    1
    evidently!

Popular pages Recent additions subscribe to a feed