Question: Using c++ write a main function with an int array of size 10. Fill the array with random values. Print the sum of the values.
Using c++ write a main function with an int array of size 10. Fill the array with random values. Print the sum of the values.
Then use fork to create a child process.
- In child process add the elements 0-4 from array and save the result in a fie out.txt
- In the parent process add the elements 5-9 from array. Wait for the child process to finish writing and closing the out.txt file. Then open the file in parent process and get the total value of elements 0-4. Using this number print the sum of the values of the whole array (elements 0-9).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
