Question: Please modify this code to have a maximum number of 7 attempts #include #include using namespace std; int main() { int num, guess, tries =

Please modify this code to have a maximum number of 7 attempts
#include
#include
using namespace std;
int main()
{
int num, guess, tries = 0;
srand(time(0)); //seed random number generator
cout
do
{
cout
cin >> guess;
tries++; num = rand() % 100 + 1; // random number between 1 and 100
if (guess > num)
cout
else if (guess
cout
else
cout
} while (guess != num);
cin.ignore();
cin.get();
return 0;
}
A. Write a C++ program to implement the Number Guessing Game. In this game, the program selects a random number between 1 and 100, and the player (user) tries to guess the number in as few attempts as possible (max 7 attempts allowed to guess). Each time the player enters a guess, the program tells him whether the guess is too high too low, or right. Once the player guesses the correct number or he has used max number of attempts allowed, the game is over. The program should print if the player has won or lost and how many attempts he has used. The game should ask the player if he would like to play again and if answer is yes the game will start again
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
