When it comes to the part where you have yo answer yes or no, many different answers come after that instead of one. Could you explain what's wrong and how to fix it?
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
cout<<"Hello! \n"
<<"What is your name? \n";
string name;
cin>>name;
cout<<"Nice to meet you, "<<name<<"! \n";
cout<<name<<", are you a boy or a girl? \n";
string sex;
cin>>sex;
cout<<"Oh, ok. \n";
cout<<"Can I please ask you one more question? (Yes or No) \n";
bool yn; //"yn" - user's answer Yes/No
cin>>yn;
int Yes;
Yes = 1;
int No;
No = 0;
int Maybe;
Maybe = 2;
if(yn=1)
{
cout<<"Ok. How old are you, "<<name<<"? \n";
}
elseif(yn=0);
{
cout<<"Oh come on! Please, only one question. \n";
}
if(yn=2)
{
cout<<"I'll ask. How old are you? \n";
}
else
{
cout<<"Huh? Can I ask or not? \n";
}
bool age; bool answer;
cin>>age, answer;
if(age>0)
{
cout<<"That's cool! Thanks for telling me. \n";
}
elseif(answer=1)
{
cout<<"So, how old are you? \n";
}
if(0)
{
cout<<"Fine then, I am not going to ask. \n";
}
system("pause");
return 0;
}
bool yn; //"yn" - user's answer Yes/No
A bool object can be in one of two states. TRUE or FALSE. You cannot store a string in it, so this: cin>>yn;
is impossible. You cannot store a string in a bool. Do not try to store a string in a bool.
Dimm, everything dhayden just said is true but it's not something you need to do anything about so don't worry about it. Do not try to store a string in a bool.