Consider the following program main() { fork() ; fork() ; fork( ) ; } How many new processes will be created ?

Consider the following program main() { fork() ; fork() ; fork( ) ; } How many new processes will be created ? Correct Answer 7

Concept:

Fork system call is used to create a new process also called a child process or new process.

Formula:

With n fork system calls, number of new (child) processes created is 2n – 1.

Explanation:

Here there are 3 fork system calls in the given program.

new process created = 2n – 1= 23 – 1 = 7

Related Questions

What is the difference between the following 2 C codes?
#include  //Program 1int main(){ int d, a = 1, b = 2; d = a++ + ++b; printf("%d %d %d", d, a, b);}

#include  //Program 2int main(){ int d, a = 1, b = 2; d = a++ +++b; printf("%d %d %d", d, a, b);}