Multiple choice technology operating systems

Predict the output of the following program code main() { fork(); fork(); fork(); printf("Am in TCS!"); }

  1. It will get printed once

  2. it will get printed 8times

  3. it will not work

  4. It wil print three times

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Each fork() call doubles the number of processes. Starting with 1 process, after three consecutive fork() calls: 1 → 2 → 4 → 8 processes total. All 8 processes execute the printf statement, so the output appears 8 times. This is a classic example of exponential process creation in Unix systems.