Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rookie_developer

Whats the matter with this little code

This topic is 5654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am making a program that shows you what number you typed in when i compile it there says theres a parse error heres the code #include <iostream.h> int main() { int x cout <<"I am a psychic type in a number and ill guess it" endl; cin >>x; cout <<"Tell me if im right is it" <

Share this post


Link to post
Share on other sites
Advertisement
I think it should be:


#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int x;
cout <<"I am a psychic type in a number and ill guess it"<<endl;
cin >>x;
cout <<"Tell me if im right is it" <<x+7 <<"no? How about" <<x-5 <<"come on well its gotta be" <<x;
getch();
return 0;
}


[edited by - programmer evil sausage on June 17, 2003 2:18:53 PM]

[edited by - programmer evil sausage on June 17, 2003 2:21:28 PM]

Share this post


Link to post
Share on other sites
Check your semi-colons ( ; ), and the last line.

cout <<"Tell me if im right is it"


Should be:


cout << "Tell me if I'm right is it: " << x;
return 0;




Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?"
- The Boondock Saints



[edited by - Rob Loach on June 17, 2003 2:36:03 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include <iostream>
using namespace std
int main()
{
int x
cout <<"I am a psychic type in a number and ill guess it" << endl;
cin >>x;
cout <<"Tell me if im right is it:" << x << endl;
}
system"PAUSE"

Share this post


Link to post
Share on other sites
or you could just say...



#include <iostream.h>
int main()
{
int x;
cout <<"I am a psychic type in a number and ill guess it" <<endl;
cin >>x;
cout <<"Tell me if im right is it";
cout << x;
return 0;
}


lets see if i can actually post source this time.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
oops

system "pause"
should read system ("PAUSE"

Share this post


Link to post
Share on other sites
I think the error you are receiving is because of this bit:

...will guess it" endl;

You are missing the << before endl;

...will guess it" << endl;

It also wouldn''t hurt (for readability) to make it:

...will guess it"
<< endl;

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!