samedi 27 décembre 2014

the no option in my if-else statement isnt working correctly

i wrote this code to use the if-else statement but the "no" outputs the same as the yes, i first tried declaring the yes and no variables locally and that fixed the first error i got, but now they are not differentiating the output. the condition for yes outputs no matter what i try. here is the code below:



#include<iostream>
#include<string>
using namespace std;
int main()
{
string name;
bool answer;
cout<<"Welcome user 'Divine 9'..."<<"What is your name?"<<endl;
getline(cin, name);
cout<<endl<<"Hello "<<name<<", my name is Xavier."<<endl<<" I am going to ask you some questions about yourself. Fear not, i will not take any of your information back to the boss man, or store it."<<endl;
cout<<"Is this okay with you? (yes/no)"<<endl;
cin>>answer;
{bool yes;
bool no;
if(answer==yes)
cout<<"Great, will proceed with the questions!"<<endl;
else (answer==no)
cout<<"That is okay, still love the Gamma Sig ladies, especially that_girl_teejay :-)";}

return 0;
}


can someone please help me figure this out, i thought i had it but i guess i dont


Aucun commentaire:

Enregistrer un commentaire