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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.