Task 5 (20 points) In this task, you will design and implement a program to use
ID: 3576282 • Letter: T
Question
Task 5 (20 points) In this task, you will design and implement a program to use multiple processes to calculate the average of an integer array. Your program will do the following 1. Open a file named number.dat for reading (use fopenO) 2. Read the first number from that file (use fscanfo) The first number will indicate the size of the array. 3. Use mallocO to allocate space for the array. 4. Read in the array on number at a time using fscanfo 5. forkO a new process 6. The parent process will calculate the sum of the first half of the array 7. The child process will calculate the sum of the second half of the array. 8. The child will send its result to the parent using a pipeO then it will exit. 9. The parent process will receive the result and calculate the average for the whole array and print it out to standard output Name your program avearge.c. This skeleton code will fork0 a child process, the child process will send a number to the parent then the parent will print it out to standard output. Remember to close the files and free the pointer before exiting. Your program should work like this: hb 117 uxb4 gcc average c -o average hbo 11 7Quxb4 /average The average is 32716.061050 auxb4Explanation / Answer
we can write a method and to print the user defined value....
for that we can create
int display(int argc,char argv**){
//add the stuff related to defined values...
now pass the args from return statement to the method to be executed....
return agrs;
int displayData(int args){
//get the data to be printed and clear the malloc to reduce the memory and increase the performance....
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.