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

#include #include#include# define SIZE 4 void generate_answer(int[]); void compa

ID: 3529166 • Letter: #

Question

#include #include#include# define SIZE 4 void generate_answer(int[]); void compare(int[],int[],int *,int *); int main() {int guess[SIZE],answer[SIZE]; int i,n,m,guesses; int number,exact,inexact; double average; srand(0); guesses=0; printf("*** Welcome to the MATCH and HIT game*** "); printf("The computer has selected a 4-digitnumber. "); printf("Try to deduce it in 12 rounds ofqueries. "); generate_answer(answer); for(i=0;i9999) {while(getchar() != ' ' ); printf("invalid input "); printf("Round# %d Please enter your query (4digits):",guesses); } m=1000; for(i=0;i<13); if(exact==SIZE) {printf("*********************************** "); printf("CONGRATULATIONS! You won thegame! "); printf("***********************************"); } else {printf("*********************************** "); printf("Sorry, out of queries. Gameover! "); printf("***********************************"); } getch(); return 0; } void generate_answer(int answer[]) {int i,j,n,dupe=0; for(i=0;i

Explanation / Answer

the problem is with srand(0) ; do this simple change include the time.h header file and change srand(0); ---- > srand(time(NULL)); this will generate new random input each time you call it, the reason is 0 is constant so always it generates input corresponding to 0. but if u write time(NULL) in place of 0, it gets current time in microseconds, which changes everytime you run the code...and so your input also changes.