help again please

This is a discussion on help again please within the C++ Programming forums, part of the General Programming Boards category; c:\documents and settings\owner\my documents\lessons\untitled1.cpp: In function `int main()': c:\documents and settings\owner\my documents\lessons\untitled1.cpp:5: parse error before `<' c:\documents and settings\owner\my documents\lessons\untitled1.cpp:6: ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    6

    help again please

    c:\documents and settings\owner\my documents\lessons\untitled1.cpp: In function `int main()':
    c:\documents and settings\owner\my documents\lessons\untitled1.cpp:5: parse error before `<'
    c:\documents and settings\owner\my documents\lessons\untitled1.cpp:6: parse error before `:'

    #include <iostream.h>
    int main ()
    {
    int thisisanumber
    cout <<"please enter a number; " ;
    cin >>thisisanumber :
    Cout<< "you entered: " <<thisisanumber;
    return 0;
    }




    what is the problem with this code?

  2. #2
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    Start by changing

    int thisisanumber

    to

    int thisisanumber;

    Cout<< "you entered: " <<thisisanumber;

    to

    cout<< "you entered: " <<thisisanumber; (maybe not sure if it's case-sensitive)

    cin >>thisisanumber :

    to

    cin >>thisisanumber ;

  3. #3
    CodeGoddess
    Guest

    Talking

    You forgot a ; after your int declaration and you used a : instead of a ; after your cin statement.

    Gretchen

  4. #4
    Ice_Black
    Guest

    Smile

    #include <iostream.h>
    int main () {
    int thisisanumber;
    cout <<"please enter a number";
    cin >> thisisanumber;
    cout <<"you entered: " <<thisisanumber;
    getch();
    return 0;
    }

    this should work.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by Ice_Black
    #include <iostream.h>
    int main () {
    int thisisanumber;
    cout <<"please enter a number";
    cin >> thisisanumber;
    cout <<"you entered: " <<thisisanumber;
    getch();
    return 0;
    }

    this should work.
    actually, getch() is in conio.h

  6. #6
    _ Munkey01's Avatar
    Join Date
    Dec 2002
    Posts
    280
    Originally posted by minesweeper
    cout<< "you entered: " <<thisisanumber; (maybe not sure if it's case-sensitive)
    C++ _IS_ case sensitive.

    For people who do not know what case sensitivity is-
    means joe can be made into 7 different variables by using different case's-

    JOE
    JoE
    Joe
    JOe
    jOe
    jOE
    joE

  7. #7
    Ice_Black
    Guest
    Originally posted by alpha
    actually, getch() is in conio.h
    O yeah, forgot about conio.h header :P

    thanks for pointing me with this.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by Ice_Black
    O yeah, forgot about conio.h header :P

    thanks for pointing me with this.
    no problem. it was mainly to help lil_plukyduck.

  9. #9
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Munkey01
    C++ _IS_ case sensitive.

    For people who do not know what case sensitivity is-
    means joe can be made into 7 different variables by using different case's-

    JOE
    JoE
    Joe
    JOe
    jOe
    jOE
    joE
    Come on -- powers of 2! Not 7 possibilities, it's 8!

    There's 3 letters each with 2 possibilities. That's 2^3 which is 8 different possibilities, not 7.

    As a programmer, just look at it as a 3 digit binary number. 3 binary digits can represent 8 different values.

    In case you're wondering, the one you missed was joe (all lowercase).

    000
    001
    010
    011
    100
    101
    110
    111

  10. #10
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Wow, you're really something else, Poly. 'Just think of it as binary.' Yeah, like that'll help the newbies remember how to calculate statistics
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  11. #11
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    lol...the newbies can ignore it though. they'll eventually learn it.

  12. #12
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    The first thing I learned before C++ was binary. Isn't that sort of standard? I learned binary, octal and hex before doing any coding.

  13. #13
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    An added information

    getch() is a non-standard function. Its good coding practice to avoid non-standard functions.

    I believe that you wanted the output screen to just PAUSE at the end of the execution, why don't you try

    system("give the OS command that is used to pause within this quote");

    // stdlib.h is the headerfile for system


    you could even have a dummy input statement instead

    I wonder how "Polymorphic OOP" missed this ????
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  14. #14
    _ Munkey01's Avatar
    Join Date
    Dec 2002
    Posts
    280
    Originally posted by Polymorphic OOP
    Come on -- powers of 2! Not 7 possibilities, it's 8!

    There's 3 letters each with 2 possibilities. That's 2^3 which is 8 different possibilities, not 7.

    As a programmer, just look at it as a 3 digit binary number. 3 binary digits can represent 8 different values.

    In case you're wondering, the one you missed was joe (all lowercase).

    000
    001
    010
    011
    100
    101
    110
    111
    Sorry, math is not my strongest point. LOL. Thanks for correcting me.

  15. #15
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109

    Re: An added information

    Originally posted by shiv_tech_quest
    getch() is a non-standard function. Its good coding practice to avoid non-standard functions.

    I believe that you wanted the output screen to just PAUSE at the end of the execution, why don't you try

    system("give the OS command that is used to pause within this quote");

    // stdlib.h is the headerfile for system


    you could even have a dummy input statement instead

    I wonder how "Polymorphic OOP" missed this ????
    actually the dummy input statement is a good idea. but the system calls are OS dependent.

    poly, I haven't really learned much, I know some binary, the idea of powers of two, and 0 is false and 1 is true. maybe because i'm still in high school. I probably will in college, learn binary, hex, etc. and technically, i would say, i'm still a newbie.

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