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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!