Question: Guessing game C++ I need help figuring out how to keep track of the FIRST THREE INPUTS from the user and print them at them

Guessing game C++

I need help figuring out how to keep track of the FIRST THREE INPUTS from the user and print them at them out at the end using an array, so far this is my code feel free to completely change it if needed.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include // Used for cin and cout #include // Used to generate random number using rand method #include // Used to be able to use string #include // Used to reset the machine time to generate different random numbers

using namespace std; // making life easier so that we do not need to use std::cin , std::cout, etc.

int main() { /*Seed the random number generator*/ srand(static_cast(time(NULL)));

int targetNumber = rand() % 100; // generates a random number from 1 to 100

cout << "Let's play a Number Guessing Game! What is your name ?" << endl; string name; cin >> name; cout << "Hello, " << name << "! Now let us play the game! " << endl; /******************************************************** This is a Hi-Low game. A random number from 1 to 100 is generate. 1. Ask the user to guess the number. 2. If the user guess right, print bingo. The game is over. 3. If the user's guess is too high or too low, the program informs the user of that fact and asks for another guess. 4. This repeats until the user gets the number correct. **********************************************************/

// *************To DO***********************

int usernum = 0;

while (1) { cout << "Guess a number so that the computer can compare with the guessed number"; cin >> usernum; if (usernum > targetNumber) cout << "sorry your number is too high" << endl; else if (usernum < targetNumber) cout << "sorry your number is too low" << endl;

else {

cout << "BINGO" << endl; break; } }

/********* BONUS POINT********* keep track of the first three numbers that user guessed and print them out at the end Hint: You can use array to store these 3 numbers ******************************/

system("pause"); return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!