Menu

Please C Functions Modify Guessing Game Write Secret Number File Write User Guess Answer F Q43897186

please c++ with functions *Modify the Guessing Game Write thesecret number to a file. Then write each user guess and answer tothe file. (on separate lines) Write the number of guesses to thefile at the end of the game. After the game is finished, ask theuser if they want to play again. If ‘n’ or ‘N’ don’t play again,otherwise play again! NOTE: your file should have more than onegame in it if the user plays more than one game. Don’t forget -pseudocode, comments, proof of testing. Post file(s) in digication,then post link on MOODLE. SLOs: code modification file writinglooping algorithm modification*/ #include #include //for rand andsrand #include //for the time function using namespace std; intmain() { srand(time(0)); // Seed the random number generatorsrand(NULL); //asking user if he/she likes to play a game cout<< “Would you like to play a game? “; char ch; // choices cin>> ch; // if choice is ‘Y’ or ‘y’ if (ch == ‘Y’ || ch == ‘y’){ //generating a random number between 1 and 10 int randNum =(rand() % 10) + 1; int guess; //asking and reading a guess cout<< “Guess a number between 1 and 10: “; cin >> guess;//if guess is same as number, if (guess == randNum) { cout <<“Bingo” << endl; } //if guess is smaller than number, else if(guess < randNum) { cout << “too low” << endl; }//if guess is bigger than number, else { cout << “too high”<< endl; } } return 0; }

Expert Answer


Answer to please c++ with functions *Modify the Guessing Game Write the secret number to a file. Then write each user guess and an…

OR