new to c++ need help

This is a discussion on new to c++ need help within the C++ Programming forums, part of the General Programming Boards category; HI All I have just started to learn c++ from the tutorials on this website and have got a problem ...

  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,185
    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

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