Question: Upload a . c source file containing a main function that will implement the following program. Your program will implement a text - based game

Upload a .c source file containing a main function that will implement the following program. Your program will implement a text-based game that the user plays against the computer.
Both the player and the computer start with 10 points.
During a round of the game, the player starts by entering an integer value. This value is normally between 1 and 3 included. However, since it is meant to be subtracted to the points that the player has, they cannot enter a value greater than the number of points they have left. For instance, if a player has only 2 points left, then they can only enter a value between 1 and 2 instead of 1 and 3.
Once a valid value has been entered (see below for how to handle invalid input), the computer generates a random integer value, also between 1 and either 3 or whatever the number of points it has left is if it is below 3. For instance, the computer has 10 points left, they will generate a random number between 1 and 3. If they had only 1 point left, they would have to generate a random number between 1 and... well... 1.
The winner of the round is whoever has entered the largest value. If both values are the same, then no one wins. When the player wins a round, their score is incremented by one (starting at 0 at the beginning of the game).
As soon as either the computer or the player run out of points, the game ends and the player's score is displayed. The score is computed by adding the actual score to the number of points the player has left.
See the example of program's execution section below for more details about the requirements.

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 Programming Questions!