Question: c language~ You will develop a program summation_many that takes a list of one or more files on the command line. You will need to
c language~
You will develop a program summation_many that takes a list of one or more files on the command line. You will need to compute the summed powers over all of the floating point numbers across all of the files to produce a single number as output.
Assume that you have text files with numbers separated by newlines. You want to read the numbers in from all the files. Since you want to be flexible on the type and size of numbers your program can handle, you should use a double floating-point.
If a file appears multiple times on the command line, those numbers will be processed multiple times.
You should use fork() to start a process for each of the files so that we can compute sums for each file individually in parallel. To communicate between processes you will use pipe(). You need to wait for all the processes to finish using wait().
You must be able to handle files with any number of numbers (including no numbers). You can assume that the files are well formed: they will contain only valid numbers separated by newlines (and possibly an occasional empty line, same as in assignment 1).
The code/ipc directory contains examples of using fork, pipe and wait, which you can consult for help.
numbers.text
1
2
3.5
0
4
For example, running on numbers.txt will output:
./summation_many numbers.txt 1
will output:
10.50
./summation_many numbers.txt numbers.txt 1
will output:
21.00
./summation_many numbers.txt morenumbers.txt 1
will output the following, assuming morenumbers.txt only contains the number 6.0:
16.50
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
