Write a C program using the fork() system call that calculate the factorial in the child process. The number will be provided from the command line. For example, if 5 is passed as a parameter on the command line, the child process will output 120. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the result. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a positive integer is passed on the command line.
OUTPUT
Enter the value of n: 5
The factorial of 5 is 120
Comments
Leave a comment