Write a shell script, guess.sh that implements a simple number guessing game.
When run, the shell script prompts the user to guess a random number between 0
and 100.

If the user guesses incorrectly, the script prompts the user “Guess
higher” or “Guess lower” as appropriate and allows the user to guess again.

If the user guesses correctly, the script terminates printing out how many guesses the
user needed.
For example:

Guess my secret number (0­-100): 101
Thats not between 0 and 100
Guess my secret number (0­-100): 80
Guess higher
Guess my secret number (0­-100): 85Guess lower
Guess my secret number (0­1-00): 82
Right! You guessed my secret in 3 guesses.

Recommended Answers

All 2 Replies

then???

I'm sure the assignment was due well before this, so here goes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.