Please use code tags instead, and watch spaces like in using namespace or else if .
#include<iostream>
using namespace std;
int main()
{
int age;
char sex;
cout<<"please input your age:";
cout<<"please input your sex (M/F):";
cin>> age;
cin>> sex;
if ( age < 100 )
{
cout<<"you are pretty young!\n";
}
else if ( age ==100 && sex == 'm' )
{
cout<<"you are pretty old,and you are male!\n";
}
else if ( age ==100 && sex == 'f' )
{
cout<<"you are pretty old, and u r a female!\n";
}
else
{
cout<<"You are relly old!\n";
}
}
Any problem with this?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
The same program works fine with me.
Which OS and compiler (version) are u using?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
There must be some information that you can see that you're not telling us. How did you set up the project? Are there other files in it? Etc.?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
You can have more files, but as the linker seems to be telling you, you can't have the same thing defined in more than one place. I don't suppose you'd care to post all the relevant code?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Well there you go. You've got main defined in more than one file. You can only have one main . Just like the messages are saying. You need a single entry point to your program -- decide where it should be.
And again, if you want help with code, it is highly advisable that you post the code you want help with.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Make it a function called something other than main , then call it from the other code.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314