IN C Thank you Make sure when you write your program to pu
[ IN C++ ] Thank you... Make sure when you write your program to put a picture of your output.
(Guess the Number Game) Write a program that plays the game of \"guess the number as follows: Your program chooses the number to be guessed by selecting an integer at randomintherange 1 to 1000. The programthen displaysthefollowing I have a number between 1 and 1000. Can you guess my number? Please type your first guess. The player then types a first guess. The programrespondswith one ofthe following: 1. Excellent! you guessed the number! Would you like to play again (y or n? 2. Too low. Try again. 3. Too high. Try again If the player\'s guess is incorrect, your programshould loop until the player finally gets the number right. Your program shouldkeep telling the player Too high or Too low to help the player \"zero in\" on the correct answer. Note: you need to have more than one file in this labSolution
Hi buddy, please find the below CPP program
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main() {
const int LOW = 1;
const int HIGH = 1000;
time_t sec;
time(&sec);
int again = 1;
while(again==1){
cout << \"I have a number between 1 to 1000.\ Can you guess my number?\ Please type your first guess.\ \";
srand((unsigned int) sec);
//Generating the random guessed number
int guess = rand() % (HIGH - LOW + 1) + LOW;
// cout << guess <<endl;
int user;
//This loop continues till user guesses the right number
while(true){
cin >> user;
if(user==guess){
cout << \"Excellent! You guessed the number ! would you like to play again?\ \";
cin >> again;
break;
}
if(user>guess){
cout << \"Too High. Try again\ \";
}
else{
cout << \"Too Low. Try again\ \";
}
}
}
return 0;
}
OUTPUT:
I have a number between 1 to 1000.
Can you guess my number?
Please type your first guess.
346
Too Low. Try again
689
Too High. Try again
590
Too High. Try again
450
Too Low. Try again
543
Excellent! You guessed the number ! would you like to play again?
0
Too Low. Try again
![[ IN C++ ] Thank you... Make sure when you write your program to put a picture of your output. (Guess the Number Game) Write a program that plays the game of \ [ IN C++ ] Thank you... Make sure when you write your program to put a picture of your output. (Guess the Number Game) Write a program that plays the game of \](/WebImages/34/in-c-thank-you-make-sure-when-you-write-your-program-to-pu-1101956-1761582430-0.webp)
![[ IN C++ ] Thank you... Make sure when you write your program to put a picture of your output. (Guess the Number Game) Write a program that plays the game of \ [ IN C++ ] Thank you... Make sure when you write your program to put a picture of your output. (Guess the Number Game) Write a program that plays the game of \](/WebImages/34/in-c-thank-you-make-sure-when-you-write-your-program-to-pu-1101956-1761582430-1.webp)