Consider the following C programe is executed on a Unix /Linux system:
#include<unistd.h>
int main()
{
int i ;
for (i = 0; i < 10; i++)
if (i % 2 = = 0)
fork ():
return 0;
}
The total number of child processes created is _____.
Open in App
Solution
Number of child process created using n fork ()
calls =2n−1
fork (); statement inside the loop executed when i =0, 2, 4, 6, 8. So n = 5 times fork () is executed.