CodePudding user response:
#include#include
{int the add (int num1, int num2)
Return num1 + num2;
}
{int multiply (int num1, int num2)
Return num1 * num2;
}
Void fork_test (int num1, int num2) {
Pid_t pid;
If ((pid=fork ()) & lt; 0)
Printf (" fork error ");
Else if (pid==0) {
Printf (" son process: add two Numbers. \ n ");
Int sum=add (num1, num2);
Printf (" % d % d=% d \ n ", num1, num2, sum);
}
The else {
Sleep (2);
Printf (" the parent process: multiply two Numbers. \ n ");
Int result=multiply (num1, num2);
Printf (" % d % d *=% d \ n ", num1, num2, result);
}
}
Int main () {
Fork_test (15, 10);
return 0;
}