for(i=0;i<5;i++)
for(i=0;i<5;i++)
fork();
for(int i=0; i<n; i++)
fork();
For such kind of situation the total no of processes created is always 2^n - 1
as fork()
will get called by n
time.
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
fork();
For this double for-loop
, fork()
gets called by n^2
times, Hence total no of processes created will be,
2^(n^2) - 1
What is important for such questions is to calculate the no of times your fork()
gets called.
For you case n=5
so total no of child processes will be 2^25 - 1
.