Open In App

Algorithms Quiz | SP Contest 3 | Question 7

Consider the below C program:




int main()
{
    fork();
    fork();
    fork();
      
    printf("Hello World");
}

How many child processes will be created when the above program executes?
(A) 4
(B) 5
(C) 6
(D) 7

Answer: (D)
Explanation: For n fork calls in a program, (2n-1) child processes are created.

Here n = 3.
Therefore, no of child process = 23 – 1 = 8 – 1 = 7.

Quiz of this Question

Article Tags :