Revaluing x and cin.get(); needed in if
If I were making a if thing say
Code:
include <iostream>
using namespace std;
int main()
{
cout<<"Please select 1 or 0\n";
cin<< x;
cin.ignore;
if ( x == 0 ) {
cout<<"Hi, you were wrong, please choose again\n";
cin<< x;
cin.ignore
if ( x == 1 ) {
cout<<"Yay, you got it right!\n";
cin.get();
}
else if ( x == 1 ) {
cout<<"Well done!\n";
cin.get();
}
else {
cout<<"I said 1 or 0, pick again!\n";
cin<< x;
cin.ignore;
if ( x == 1 )
cout<<"Yay!\n";
}
Do I need the cin.get(); and how do you revalue x? Don't worry about other mistakes I just made this up on the spot. Thanks :p