Menu

Guessing Game C Need Help Figuring Keep Track First Three Inputs User Print End Using Arra Q43860698

Guessing game C++

I need help figuring out how to keep track of the FIRST THREEINPUTS from the user and print them at them out at the end using anarray, so far this is my code feel free to completely change it ifneeded.

—————————————————————————————————————————————————————————-

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

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

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

   int targetNumber = rand() % 100; // generates arandom 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 << “! Nowlet us play the game! ” << endl;
  
  /********************************************************
   This is a Hi-Low game. A random number from 1 to 100is generate.
   1. Ask the user to guess the number.
   2. If the user guess right, print bingo. The game isover.
   3. If the user’s guess is too high or too low, theprogram informs the user of that fact and asks for anotherguess.
   4. This repeats until the user gets the numbercorrect.
  **********************************************************/

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

   int usernum = 0;
  

   while (1)
   {
       cout << “Guess a number sothat 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;
       }
   }
  

       /********* BONUSPOINT*********
       keep track of the first threenumbers that user guessed and
       print them out at the end
       Hint: You can use array to storethese 3 numbers
       ******************************/

       system(“pause”);
   return 0;

}

Expert Answer


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

OR