Computer generates a random sequence of 0s and 1s creating


The computer generates a random sequence of 0s and 1s creating a binary number. In each round, the computer adds one more bit to the previous sequence, only displaying the added bit. The user then needs to enter the decimal value of the binary number represented by the sequence of 0s and 1s displayed so far.

At the beginning of the game, the computer asks the user to provide a number between 0 and 5 to be used as the number of mistakes allowed per game.

A mistake happens every time the user enters a wrong decimal number. When the user exhausts the number of allowed mistakes, the game terminates and the user loses.

For example, consider a game allowing 2 mistakes: the third time the user makes a mistake, the game ends and the user loses. However, if the user enters the correct decimal number, then the computer adds one more binary digit to the sequence and the game continues. Except for the new bit added at the end, the rest of the sequence remains the same as the sequence produced in the previous round. If the user manage to guess correct for 15 times, end the game by printing the user is too smart for this.

Goto and break are not allow in the loop.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Computer generates a random sequence of 0s and 1s creating
Reference No:- TGS0952118

Expected delivery within 24 Hours