C program takes an integer argument from command line


Discuss the below:

Create 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.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: C program takes an integer argument from command line
Reference No:- TGS01933754

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)