game code error

this is a simple game to guess a die number:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){



srand(static_cast<unsigned int>(time(0)));
int randomNumber=rand();
int die=(randomNumber%6)+1;
bool success;
success=true;
int playerturn;

do {
cout <<"guess your number";
cin >> playerturn;
if ( playerturn==die ){
success=true;
}
else { success!=true;
if (playerturn>die){
cout << "too high" << endl;
}
else {
cout << "too low" << endl;
}
}
while (success!=true);



cout << "this is the right number" << endl;




system("pause");
return 0;
}


there are errors, but I don't know what ?
this line else { success != true; is your problem, what you're doing there is comparison, not assignment, success != true compares success to true and returns a bool result, it doesnt set success to anything, you should be setting it to false success = false

also, please use code tags when posting code.
Last edited on
thank you, but still I have error. the last brace is marked and written under it expected while. why ?
actually add another } after your cout
Topic archived. No new replies allowed.