Question: You are required to write a C program that uses multithreading to create a guessing game. In this game, parent thread choses a number between

You are required to write a C program that uses multithreading to create a guessing game. In this game, parent thread choses a number between 1 and 10 and child thread guesses that number. Please note the followings:

Parent thread should choose a different number (int) at each run of the program

Parent thread should display the number it has chosen

Parent thread passes that number to the child thread function as a parameter by reference

Child function keeps on guessing the number till it gets it right

When child thread gets the number right, it shows that number with a message (see expected output screenshot) and it straight away exits

Child thread should keep track of number of tries and at each guess, it should display the try number (please refer to the screenshot for more details)

Make sure to differentiate between the messages from child and parent thread (see screenshot below for more details)

Finally, child thread merges into the parent and the program exists.

You are required to write a C program that uses multithreading to

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!