Write a C program that creates multiple threads to perform the following tasks: Generate an array of random integers of size N (N is an input from the user). Find the sum of all the elements in the array using multiple threads. Calculate the average of all the elements in the array using multiple threads. Print the sum and average of the array. The program should create two threads: one to find the sum of the elements in the array and another to calculate the average of the elements in the array. The array should be passed as an argument to the threads, and each thread should work on a separate part of the array. The main thread should wait for both threads to finish and then print the sum and average.
Write a C program that creates multiple threads to perform the following tasks:
Generate an array of random integers of size N (N is an input from the user).
Find the sum of all the elements in the array using multiple threads.
Calculate the average of all the elements in the array using multiple threads.
Print the sum and average of the array.
The program should create two threads: one to find the sum of the elements in the array and another to calculate the average of the elements in the array. The array should be passed as an argument to the threads, and each thread should work on a separate part of the array. The main thread should wait for both threads to finish and then print the sum and average.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images