Write a C program that takes an integer argument from the command line and outputs the sum of all digits of the integer. For example, the result of the invocation sum of digits 12345 should be 15.
The program has two constraints:
1) Each process can do at most one addition. If you want to calculate the sum of more than two digits, you will have to fork one or more processes in order to do that, and each of the forked processes in turn can process at most one more addition before forking further more process(es) to compute the sum.
2) Each process can fork at most one other process.© BrainMass Inc. brainmass.com July 16, 2018, 10:22 pm ad1c9bdddf
Please find attached an implementation (525108.c) to achieve the goal. Please be aware that this is not the only way to go about it, that is, many approaches are possible in this case.
Attached program has been tested for ...
GNU C compiler (gcc) version 4.3.4 was used during the development of attached program is in the attached Excel file. It also prints information messages indicating what addition is being performed by which process.