Keeping track of score(guessing game with an array)

Hello again, I have recently modified my code to be played again, but I would like to keep track of the number of guesses, and display the lowest score. Any help would be appreciated. :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  #include <iostream>
#include <cstdlib>
#include <ctime>
using namespace 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, 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;
	
		}
	    else if(answer='Y')
		{
			playagain=false;
		}
		
	}

	 else if (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;

}
}

closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/178364/
Don't double post please
repeat topic. Marking as solved.
Topic archived. No new replies allowed.