Question: Using the flowchart provided for the game of Mastermind, create a C program Start print: Welcome to the game of mastermind! Print: I will select

Using the flowchart provided for the game of Mastermind, create a C program

Using the flowchart provided for the game of Mastermind, create a Cprogram Start print: "Welcome to the game of mastermind!" Print: "I willselect a random 4-digit number using digits 1 to 9 and youvill attempt to guess my number. InYou only have 10 rounds souse your choices wisely. To help you identify this number, I willtell you how many of your digits occur in exactly the sameposition as in my number, and how many digits occur in my

Start print: "Welcome to the game of mastermind!" Print: "I will select a random 4-digit number using digits 1 to 9 and you vill attempt to guess my number. InYou only have 10 rounds so use your choices wisely. To help you identify this number, I will tell you how many of your digits occur in exactly the same position as in my number, and how many digits occur in my number but in a different position Press l if you would like to play or press any number to exit "); loop Numbers= ["1", "2", "3", "4", "5", "6","7", "8", "9"} computerNumberl= picks random number from Numbers computerNumber2= picks random number from Numbers computerNumber 3= picks random number from Numbers computerNumber 4= picks random number from Numbers Loop (repeat 10 times) guess Numberl = INPUT ("Enter First Number") guess Number2 = INPUT ("Enter Second Number") guess Number3 = INPUT ("Enter Third Number") guess Number4 - INPUT ("Enter Fourth Number") Correct LocationAndNumber - 0 Correct NumberWrongNumber If False guessNumberla computer Number 1 True Balse Correct LocationAndNumber+=1 If Auess Numberl computer Number2 OR guessNumberl - computer Number3 OR GuessNumberly computerNumder True Correct NumberWrong Location=1 False guess Number2==> computerNumb72 True If AuessNumber2 computerNumberi OR False Correct LocationAndNumber+=1 guessNumber2 == computerNumber3 OR SuessNumber2=7 computerNumber4 True CorrectNumberWrongLocation+=1 If guess Number 3->> coxputerNumber3 True False Correct LocationAndNumber+=1 If Auess Number computerNumberi OR guessNumber3 == computer Number2 OR Suess Number 3-7 computerNumber 4 True Correct NumberWrong Location+=1 If False guess Number4-> coxputerNumber 4 If AuessNumber4 computerNumberl OR guessNumber4 == computerNumber2 False Correct LocationAndNumber+=1 OR SuessNumber4 computerNumber3 True CorrectNumberWrong Location+=1 OUTPUT Kou have" + Correct LocationAndNumber + "digits in the correct location and" + Correct NumberWrongLocation+ " digits in the wrong location if False Correct LocationAndNumber True EXIT LOOP False CorrectLocationAndNumber True OUTPUT "Congratulations, you win" OUTPUT "Sorry, you lost" YES Would you like to play again?" YES Would you like to play again?" No End

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