Write a Guess My Number Game program The program generates a

Write a \"Guess My Number Game\" program. The program generates a random integer in a specified range and the user (the player) has to guess the number The program am allows the user to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again. The basic algorithm is as follows. The program starts by printing instructions on the screen. For every game: the program generates a new random integer in the range from MIN to MAX. Treat MIN and MAX like constants; start by initializing them to 1 and 100 loop to prompt the player for a guess until the player correctly guesses the integer for each guess, the program prints whether the player\'s guess was too low, too high, or correct. At the conclusion (when the integer has been guessed): print the total number of guesses for that game. print a message regarding how well the player did in that game (e.g., the player took way too long to guess the number, the player was awesome etc); to do this, you will have to decide on ranges for your messages and give a rationale for your decision in a comment After all games have been played, print a summary showing the average number of guesses.

Solution

This is a guessing game
count=0;
real_number=rand(1);
real_number=10*real_number;
number=ceil(real_number);

fprintf(\'the number should be between 1 and 100\ \');
pick=input(\'Please guess a number: \');

while pick~= number
     count = count + 1;
     if pick>number
          fprintf(\'Then your guess is too high!\ \');
          pick=input(\'Please choose another number: \');
     else
          fprintf(\'Now your guess is too low!\ \');
          pick=input(\'you should be now guessing another number: \');
     end
end

count= count + 1;
fprintf(\'WOW!!!!1You guessed the correct number in %g shots. \ \', count);

 Write a \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site