Consider the following program. main() { fork(); fork(); fork(); } How many…

2015

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

  1. A.

    8

  2. B.

    6

  3. C.

    7

  4. D.

    5

Attempted by 611 students.

Show answer & explanation

Correct answer: C

Each fork() call doubles the number of processes. Starting with 1 process, after three forks: 2^3 = 8 total processes. Subtracting the original process gives 7 new processes created.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Isro