hop of those help? First of all the formula you are using to calculate the random number is wrong. Suppose that min is 10, and max is 12. Then the rand() % max could be, let's say, 10. Adding min (10), the number to guess would be 20 - far greater than max... It should be secret = rand() % (max-min +1) + min; (if your interval is [min, max]).

Now to your question - as far as I understood you want to know if the entered guess is a number. Here is what you can do:

code :

```
while(1)
{
cin >> guess;
if(cin){
if (guess > max){
cout << "Too high!\n\n";
cin.clear();
cin.ignore();
continue;
}
else if (guess < min){
cout << "Too low!\n\n";
cin.clear();
cin.ignore();
continue;
}
else if(guess != secret){
deposit-=bet;
cout<< "Sorry, U lose RM "<< bet;
}
else if(guess == secret){
bet*=10;
deposit+=bet;
cout<< "\n\nCongratulation! U earn RM "<< bet;
}
break;
}
else
{
cin.clear();
cin.ignore();
cout << "Error! You did not enter a number!" << endl;
continue;
}
}
```

```
do{
cout<< "Wanna play again (y/n)? ";
cin>> reply;
if( reply!='y'&& reply!='n')
cout<< "\nReally? Ok, try again! \n";
}while(reply!='n' && reply!='y');
if( reply =='y')
goto AA;
if(reply=='n'){
cout<< "\n\n\n"<< setw(80)<< setfill('+')<< "\n\n";
cout<< setw(30)<< "THX FOR PLAYING! UR CURRENT BALANCE IS RM "<< deposit<< "\n\n";
cout<< setfill('+')<< setw(80)<< "\n";
}
```

```
cout << "Pls enter the min of secret number\n";
while (!(cin >> min) || min<=0){
cout << "Pls enter the min of secret number\n";
cin.clear();
cin.ignore();
}
```