Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is C program assignment. Please answer as soon as possible thanks Write a program to accept an array of 20 elements and a number

This is C program assignment. Please answer as soon as possible thanks

Write a program to accept an array of 20 elements and a number to search in the main function, both array and the search-number should be global variables. Write a thread function to search and count the occurrence of the given number. Give a sleep (4) inside the loop in the thread function to model a big process working. Call 5 thread function to do search in 5 separate sections of the array. After calling all function join all threads together and in main function display the occurrence of the number in that array. If there is a race condition identify and synchronize to get the correct output.

Let the array be

1 3 4 1 5 6 2 7 1 8 9 1 2 3 1 3 1 4 6 7

And let the number to search is 1. Divide the array into 5 and call the same thread function to count the occurrence of 1 in that section.

1 3 4 1 5 6 2 7 1 8 9 1 2 3 1 3 1 4 6 7

In main the output will be 6 1s in the array.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

3. Uncover needs:

Answered: 1 week ago

Question

23 Negotiation skills and techniques.

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago