Question: 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
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 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)


numbers.txt (12 Bytes) 1 2 3.5 0 4 and the power will be a given number for example 1 1+ 2+ 3.5 +0 + 4 = 10.5 for example 2 1^2 + 2^2 +3.5^2 +0 + 4^2 = 33.25 numbers.txt (12 Bytes) 1 2 3.5 0 4 and the power will be a given number for example 1 1+ 2+ 3.5 +0 + 4 = 10.5 for example 2 1^2 + 2^2 +3.5^2 +0 + 4^2 = 33.25
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
