Question: This program should be written in C Program Description In this assignment you are going to make a code breaking game. You are going to
This program should be written in C
Program Description In this assignment you are going to make a code breaking game. You are going to write a program that generates an n-digit code based on the difficulty level at random and let the human player guess this code. Each time the player inputs his guess, the program responds whether the guess is lower or higher than the code until the correct code is guessed. There are three difficulty levels: Easy difficulty (upto 10) Medium difficulty (upto 100) Hard difficulty (upto 1000) The objective of the game is for the player to guess the number correctly, with the least number of attempts. The player has to guess the number. The program outputs whether the number is smaller or larger than the original code. Similarly there could be 2 player game (See sample run 2). In this assignment, I want you to use functions. In particular the main function should only be calling different functions. So main should have only function calls and nothing else. If you have anything else in the main, other than function calls, you will get a zero in this assignment. This is what your main function should look like: int main(void) { int noofplayers = getNoOfPlayers(); int difficultylevel = getDifficultyLevel(); playGame(noofplayers, difficultylevel); } The getNoOfPlayers should print out:
Welcome to Number Guessing Game by
Sample run (User input in bold and italics) Welcome to Number Guessing Game by
Please choose from 0, 1, 2, 3: 1 I am thinking of a number from 0 to 10 Player 1, please enter a number from 0 to 10: 4 Player 1, your guess is lower than the real answer I am thinking of a different number from 0 to 10 for player 2 Player 2, please enter a number from 0 to 10: 5 Player 2, your guess is lower than the real answer Player 1, please enter a number from 0 to 10: 8 Player 1 is right! Your number is: 8. You did it in 2 tries. Player 2, please enter a number from 0 to 10: 8 Player 2, your guess is lower than the real answer Player 2, please enter a number from 0 to 10: 10 Player 2, your guess is higher than the real answer Player 2, please enter a number from 0 to 10: 9 Player 2 is right! Your number is 9. You did it in 4 tries. ********************************************************** Player 1 won!!! **********************************************************
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
