Hi yall,
Absolute C++ newbie here.
I would like to know how to prompt a user to enter yes or no, and then display a different msg depending on whether y or n was pressed. I am trying to set char y=1 or true and char n=0 or false. But then I am stuck at how to compare the input variable to y and n. Right now, this bad code only makes the program display the "yes" message no matter what key is pressed. Can anyone please gimme some tips? Thank you very much.
#include <iostream>
using namespace std;
void main ()
{char y,
n,
x;
y=1;
n=0;
cout<<"\nPlease enter either y or n\n";
cin>>x;
if (x=1)
cout <<"you pressed yes\n";
else
cout <<"you pressed no\n";
}