Question: Write a bash script that will repeatedly prompt the user to guess a random number between 1 and 10, inclusively, until the user correctly guesses

Write a bash script that will repeatedly prompt the user to guess a random number between 1 and 10, inclusively, until the user correctly guesses it. To generate a random number, you can use $RANDOM, which is an internal bash function that returns a pseudorandom integer in the range 0 32767. You can use the modulus operator to limit the range, plus an offset value so that its between 1 and 10, inclusively. Specifically, generate a random number between 1 and 10, inclusively. Then, in a loop, prompt the user to enter a number between 1 and 10. If the users guess is correct, then print a congratulatory message with the correct number generated by the $RANDOM function. Otherwise, if the users guess is not correct, print out an appropriate failure message and ask the user to try again. You will keep prompting the user and reading the users guess until the user guesses the number correctly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!