1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I need some help with c++!!

Discussion in 'Programming' started by chum112, Mar 8, 2007.

  1. #1
    Anyone who cold offer me some advice. It would be realy appreciated.
     
    chum112, Mar 8, 2007 IP
  2. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It was a mathematical algorithim operation of addition, subtraction and multiplication. Thankyou for your advice, it helped me to pinpoint and correct my problem. Many thanks
     
    chum112, Mar 8, 2007 IP
  3. Xangis

    Xangis Active Member

    Messages:
    182
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    78
    #3
    If you're getting errors on cin and cout, you need to make sure that you've included the iostream headers:

    #include <iostream>

    And if you're getting errors that say that your compiler doesn't understand cin adn cout, you probably need to add this line at the top:

    using namespace std;

    Or replace all your cin and cout statements with std::cin and std::cout.

    The cin and cout functions are part of the std namespace, and that was a change made a half dozen years or so ago. If you're using an old textbook it probably won't mention that.
     
    Xangis, Mar 8, 2007 IP
    chum112 likes this.
  4. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #4
    
    #include <iostream>
    main() {
    int n , m;
    cout << "Enter n and m:" << endl;
    cin >> n;
    cin >> m;
    cout << "n + m is" <<  n+m <<endl;
    cout << "n - m is" <<  n-m <<endl;
    cout << "n * m is" <<  n*m <<endl;
    }
    
    Code (markup):
    try to compile and run and let me know if you are getting any error
     
    it career, Mar 8, 2007 IP
  5. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No error now. You guys are the best. Helped me out so much
     
    chum112, Mar 8, 2007 IP
  6. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The problems came from the cin and cout and the main not being implemented like you guys said. Can't thank you enough
     
    chum112, Mar 8, 2007 IP
  7. chum112

    chum112 Guest

    Messages:
    1,131
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    expected init-declarator before "cout"?? In function `int main() ?? expected `,' or `;' before "cout" ?? .. These errrors are realy confusing me ? anyone got any ideas?

    I use name space at the top and have tried the alternative for cin and cout etc.

    ??
     
    chum112, Mar 8, 2007 IP
  8. Xangis

    Xangis Active Member

    Messages:
    182
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    78
    #8
    Post the code you're using, then we'll be better able to make sense of it.
     
    Xangis, Mar 8, 2007 IP
  9. Xangis

    Xangis Active Member

    Messages:
    182
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    78
    #9
    Sent a PM, it should get you going.
     
    Xangis, Mar 8, 2007 IP