Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION A You are required to create a game that will operate asfollows: -The p

ID: 3617022 • Letter: Q

Question

QUESTION A You are required to create a game that will operate asfollows:    -The player will guess a number between 1 and9    -The computer will then select a random numberbetween 1 and 9    -The program will then compare the two numbers,and if they are equal the player wins and his/her score isincreased by 1. If they are not equal the computer score isincreased by 1.    -The player can exit the game by entering -1.When this occurs the players score and the computer score isdisplayed on the screen and the overall winner is congratulated viaan appropriate message on the screen.    You are required to create a game that will operate asfollows:    -The player will guess a number between 1 and9    -The computer will then select a random numberbetween 1 and 9    -The program will then compare the two numbers,and if they are equal the player wins and his/her score isincreased by 1. If they are not equal the computer score isincreased by 1.    -The player can exit the game by entering -1.When this occurs the players score and the computer score isdisplayed on the screen and the overall winner is congratulated viaan appropriate message on the screen.   

Explanation / Answer

please rate - thanks #include #include #include #include int main() {int comp,human,hscore=0,cscore=0; srand(time(0)); printf("Guess a number between 1 and 9(-1 to exit game): "); scanf("%d",&human); while(human!=-1)    {while(human9)       {printf("Invalid guess ");        printf("Guess a number between1 and 9: ");        scanf("%d",&human);        }     comp=rand()%9+1;     printf("I guessed %d ",comp);     if(human==comp)        hscore++;     else        cscore++;     printf("Guess a number between 1 and 9(-1 toexit game): ");     scanf("%d",&human);     } printf(" Final score: "); printf("Human %d      computer %d",hscore,cscore); if(hscore>cscore)      printf("Congradulations youwon!!! "); else if(cscore>hscore)      printf("I won! I won! I won!!! "); else      printf("WE TIED! ");                         getch(); return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote