Array input/output

I need the user input to be saved into my array and then output the array before the user inputs the next time. I have moving things around different ways but cannot seem to get them to perform properly. I tried to cut down the code to the two functions I am having issues with.



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
58
59
60
61
62
 
void PlayGame()
{
	
    const int HighestNum = 50;
    const int LowestNum = 1;
    int RandomNumber = LowestNum + rand() % HighestNum; //set for better random results
	
	
    cout << "Guess the random number between " << LowestNum << " and " << HighestNum << "!\n\n";

    const int attempts = 15;// limits the attempts to guess the random number to 15
	int Guess [attempts] = {};

	

		cout << "Enter your guess " << endl;

		for (int count = 0; count < attempts; count++)
		{
			
			cin >> Guess[count];
		
	
		int z = RandomNumber, y = Guess[count], r;

		r = reviewGuess (z,y);//calling the function that determines the results
		
			switch (r)//switch statement for function results, letting the user know if they matched the number, if the number is higher, or lower
			{
			case 0:
				cout << "You Win!!" << endl;
				cout << "\n";
				cin.get();
				return;                
			case 1:
				cout << "The number is higher than your guess" << endl;
                break;
			case -1:	
				cout << "The number is lower than your guess" <<endl;
                break;
			}
	
		if (count == 15)
		{
			cout << "Sorry, no guesses remain. The random number was... " << RandomNumber << "!";//so the user can see the random number at the end of their attempts
			cout << "\n";
			cin.get();
			Again();
		}
	}
	return;
}

  int DisplayGuess(int member[])
{
	for(int i = 0; i < 15; ++i)
		cout << "\nGuess " << i + 1 << ": " << member[i];
	cout << endl;
	return;
}
Topic archived. No new replies allowed.