Help?

This is a discussion on Help? within the C++ Programming forums, part of the General Programming Boards category; Hi, I am new beginner in C++ and I have question about this coding. Can anyone tell me where's the ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    5

    Help?

    Hi,

    I am new beginner in C++ and I have question about this coding. Can anyone tell me where's the error?

    if(age>=65);
    cout<<"Age is greater than or equal to 65"<<endl;
    else
    cout<<"age is less than 65<<endl";


    here's my correction, but still showing 1 error that I can't find.

    if(age>=65)
    cout<<"Age is greater than or equal to 65"<<endl
    else
    cout<<"age is less than 65<<endl";

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    88
    cout<<"age is less than 65<<endl";

    Your quotes are wrong...

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    5
    What do you mean my quotes are wrong? I am still confused

  4. #4
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    As drrngrvy said..

    Its cout<<"age is less than 65"<<endl;
    not cout<<"age is less than 65<<endl";
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    88
    Wrong as in the wrong place. You also missed a ';' on the rewrite of the code.

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    5
    Thanks guys for replying. But I am still missing a ";" any idea guys?
    error C2143: syntax error : missing ';' before 'if'

  7. #7
    ---
    Join Date
    May 2004
    Posts
    1,379
    there is a ; missing at the 'endl'
    and in your top example there is a ; after the if expression, this is wrong

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