There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer ipod itunes lan laptop malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan upgrade usb virus vista vista 32-bit windows windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Very basic c++ question


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
N.N.P's Avatar
Junior Member with 27 posts.
 
Join Date: Jul 2004
Experience: Beginner
06-Jul-2004, 08:13 PM #1
Unhappy Very basic c++ question
I found myself with some free time today so I decided I might aswell start learning C++. Needless to say i got stuck at the first error i encountered.

#include <iostream.h>
int main()
{
int x = 5;
int y = 7;
1 cout "\n";
cout << x + y << " " << x * y;
2 cout "\n";
return 0;
}


While trying to compile the above code in ms visual c++ i got 2 errors saying that i should have a semi colon in points 1 and 2. Why is this and is it correct? I took the code straight from the tutorial.

error C2143: syntax error : missing ';' before 'string' <----thats the exact error.

Thanks,
N.P.P
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
06-Jul-2004, 11:19 PM #2
You're missing an operator.

Code:
#include <iostream.h>
int main()
{
   int x = 5;
   int y = 7;
   cout << "\n";
   cout << x + y << " " << x * y;
   cout << "\n";
   return 0;
}
but why code extra lines when this

Code:
#include <iostream.h>
int main()
{
   int x = 5;
   int y = 7;
   cout << "\n" << x + y << " " << x * y << "\n";
   return 0;
}
does the same thing?
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:40 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.