Spot the error

This is a discussion on Spot the error within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> int main() { int x = 5; int y = 7; cout "\n"; cout << x + ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    12

    Spot the error

    Code:
    #include <iostream.h>
    int main()
    {
    int x = 5;
    int y = 7;
    cout "\n";
    cout << x + y << " " << x * y;
    cout "\n";
    return 0;
     }
    This was in the first quiz of "Sams teach yourself C++ in 21 days"

    Call me crazy but theres an error in line 6 and 8 that shouldn't be

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    cout "\n";

    "<<" !!!!!!!!!!!!!

    That's why I dislike this book......

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    what page is that on, I have the fourth edition btw.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    12
    Originally posted by indigo0086
    what page is that on, I have the fourth edition btw.
    4th edition? Doh! I only have the 2nd edition (downloaded)

    Its the workshop exercise for day 1.

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    they corrected it in this edition. it's as follows

    Code:
    #include <iostream>
    int main()
    {
          int x = 5;
          int y = 7;
          std::cout << "\n";
          std::cout <<  x+ y << " " << x * y;
          std::cout << "\n";
    return 0;     // you happy now >:b
    }
    Last edited by indigo0086; 09-08-2002 at 07:34 AM.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Good. Now we're just down to the missing semi-colon after 'return 0'. And the fact that we'll probably get another spate of posts that the screen disappears before you can read the display!

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    that was my error lol it has the return 0 semicolon

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM

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