
Concept explainers
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 nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

- Using one dimensional array find the Maximum number (largest) in the given data below: Index Value 0 32 1 27 2 64 3 18 4 95 5 14 6 90 7 70 8 60 9 37 Filename: ArrLargest.javaarrow_forwardWrite a java program named EmployeeRecords that simulates a company’s HR system. Theprogram reads a list of employee ids, names, and salaries from a file a3q1.txt, and stores theinformation in parallel array lists ids, names, and salaries.Sample input (a3q1.txt)132 Dumbledore 90000465 Lupin 60000443 McGonagall 75000124 Snape 70000337 Sprout 62000Your program will prompt the user to make a selection: retrieve an employee record by employeeID or display a salary report.You must include 2 methods:●retrieveEmployeeRecord(...) that accepts the array list of employee IDs and anemployee ID to find, and returns the index of the entry.arrow_forwardPlease answer the below question for operating system using shell script. write a program in bash that has a user_defined function array_sum that takes each element of array as argument andcalculates their sum. At each step the sum will printed and then the final sum will be printed. For example:Input Array:[2 3 7 9]Output: 2 5 12 21final sum: 21arrow_forward
- 2. The data array has the following numbers: 45,1,23,5,34,67 main bubble Up() OTTO A Yes Start k 0 firstUnsorted - 1 Loop first Unsorted-length_ of(data) - 1 No bubbleUp() firstUnsorted - firstUnsorted + 1 PUT K End What will be the output of this program? Yes swap() Start 16 Yes indexlength_of(data) Loop index=firstUns orted No data[index]arrow_forwardIn java Browse Project Gutenberg (https://www.gutenberg.org/) for plain text versions of one or more works of literature of your choosing. Write a program that repeatedly searches a file for a target word or phrase.• Allow the user to supply the name of the file to search by means of a command-line argument; if the user does not supply a command line argument, ask for a file name interactively.• You may use either an array or an ArrayList to store each line in the file; but if you use an array, you’ll have to determine the array size (number of lines) before allocating the array. There are several ways to do this.• Report how many lines were read from the file.• Search for either individual words or phrases (Hint: use the .contains method, it’ll work for either a word or a phrase)• Show both the line number and the line itself for each line that contains the search target entered by the user (you may count the first line in the file as line 0).• If a search word is part of a larger…arrow_forwardWrite a block of code that uses a dynamic allocated array named Array to (1) Load ten integers from the user into the memory, (2) Find the number of negative integers in the array, and (3) Print a message with the number of negatives. Whenever no numbers are negative print an additional message "No negatives!" (Assume all libraries are included)arrow_forward
- Write a program that takes an integer array and perform following operations sum, average, percentage,. The user must non zero integers. If they were not an integer, the program would throw a NumberFormatException if user try to input string instead of integer value. If denominator were Zero, the program would throw an ArithmeticException and Display the exception.arrow_forwardIn MATLABarrow_forwardSearch the web to discover the ten most common user-selected passwords, and store them in an array. Design a program that prompts a user for a password, and continue to prompt the user until the user has not chosen one of the common passwords.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





