Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needs to be in c++ Programming Challenge: 21 - Random Number Guessing Game Enhancement One way to create a pseudo-random three digit number (and we

Needs to be in c++ Programming Challenge: 21 - Random Number Guessing Game Enhancement One way to create a pseudo-random three digit number (and we are including one- and two-digit numbers as well) is rand()%1000. That gives numbers from 000 to 999, which is just what we might want for a simple guessing game. But we want to take it up a notch and have the user guess a nine-digit number. Can we just say rand()%1000000000 ? Sadly, this doesn't work. The maximum value of an int is ten digits (it is 2,147,483,647 if you really want to know) so you have (barely) enough room in the int data type to accomplish this. However - the largest pseudorandom number that our version of C++ delivers is a mere 32,767 so our method described above of getting our game numbers will not work for larger games. You will have to think outside the box on this one to get a nine-digit pseudorandom number. Let me know in a Moodle comment how you did it. Note that you should be able to guess a "hard" number in thirty tries. As specified, have the program tell the player how many guesses were used. A good player should always be able to find a three-digit number in ten or fewer guesses.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions