Write a program in C/C++/Linux to find the mean and then use that mean for
further calculations. Make three threads to perform different task as follows:
a) The 1st Thread will find the mean.
b) The 2nd Thread will take the mean from the 1st Thread and display the numbers
that are greater than the mean.
c) The 3rd Thread will also take the mean from the 1st Thread and display the
factorial of the two numbers that are the closest to the mean.
d) The Thread#2 and Thread#3 will wait until the thread#1 complete its task, and
then terminate by giving an appropriate message on the screen.
This program should take user input from command line as follows to calculate the mean:
Sample output is shown below:
[prompt]# ./file 12 7 11 14 5 7 9 4 33 65
Output starts here
Thread 1 starts
Mean = 16.7
Thread 1 ends
Thread 2 starts
Thread 2 ends
Thread 3 starts
Thread 3 ends
End of output
Jump to Post
my confusion is as syntax of thread creation is
const pthread_attr_t *attr,
void *(*func)(void *),
how i use two arguments
int argc,char * argv) in it
CODE TAGS!!!! Use them!
Which parameter in the
pthread_create()call is the *argv parameter? Same with argc. Start …
All 6 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.