Total Newbie Question

This is a discussion on Total Newbie Question within the C++ Programming forums, part of the General Programming Boards category; Hey, this is slightly embarrassing. I'm a complete newbie and most will probably laugh when you see my question or ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    2

    Total Newbie Question

    Hey, this is slightly embarrassing.

    I'm a complete newbie and most will probably laugh when you see my question or something, i'unno. Anyway, basically, I'm trying to learn C++ and I've just started today, learning about variables and some simple calculation stuff, so I decided to try making a simple program to see if I knew how to use what I learnt, so I tried this:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int Adj = 10;
        float Opp = 12.662;
        float Hyp = Opp + Adj;
        cout << "The hypoteneuse is" << Hyp << ;
        
        return 0;
    }
    I'm not really sure about the return 0, I figured I just better put it there. The compiler says that in Line 10 (the cout one), expected primary expression before ";" token? I don't know :s

    If anyone can help, that'd be appreciated...
    Last edited by Salem; 06-22-2006 at 05:41 AM. Reason: move code tag

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    20
    Change this:
    Code:
    cout << "The hypoteneuse is" << Hyp << ;
    To this:

    Code:
    cout << "The hypoteneuse is" << Hyp;

  3. #3
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    Try this
    Code:
    int main()
    {
        int Adj = 10;
        float Opp = 12.662;
        float Hyp = Opp + Adj;
        cout << "The hypoteneuse is" << Hyp <<endl ;
        
        return 0;
    }
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    2
    Ah thanks... Omg

    I tried using end1 as in endONE, not endL

    It looks like a one! lol

    And I also tried \n but I don't know why that didn't work...

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,411
    It's an escape sequence. These operate inside strings.

    Code:
    cout << "new line after this\n" << endl;
    cout << "new line after this" << "\n" << endl;
    Both produce the same output. The text "new line after this" followed by 2 empty lines (one from "\n" and another from endl.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with day of the week program
    By Punkakitty in forum C++ Programming
    Replies: 10
    Last Post: 01-14-2009, 05:55 PM
  2. Replies: 8
    Last Post: 11-03-2008, 08:48 PM
  3. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  4. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  5. total newbie question
    By Unregistered in forum C++ Programming
    Replies: 15
    Last Post: 08-16-2002, 09:38 PM

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