How do I allow the program to be replayed I have bool, and the conditionals, but it is not functioning?
Also how would I keep track of the previous tries, and display the lowest one, or "low score"
#include <iostream>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
int numberofguesses=0;
bool playagain=true;
char answer;
int guesses;
int num;
int guess;
bool isGuessed;
srand(time(0));
num=rand()%1000;
isGuessed=false;
while(!isGuessed and playagain==true){
cout<<"Enter an integer greater than or equal to 0 and less than 1000"<<endl;
cin>>guess;
numberofguesses++;
if(guess>1000 or guess<=-1)
{
cout<<"Please enter proper number, your number is out of range"<<endl;
break;
}
if(guess==num)
{
cout<<"You guessed the correct number."<<endl;
isGuessed=true;
cout<<"It took you "<<numberofguesses<<" "<<" tries to guess the correct number!"<<endl;
cout<<"Would you like to play again? Enter Y/N"<<endl;
cin>>answer;
if(answer='N')
{
cout<<"Thanks for playing!"<<endl;
}
elseif(answer='Y')
{
playagain=false;
}
}
elseif (guess<num)
cout<< "Your guess is lower than the number. Try again."<<endl;
else
cout<< "Your guess is higher than the number. Guess again!"<<endl;
}
}