InternDoor

Operating systems · 1 min · daily challenge of 2026-10-28

How many times do two fork calls print?

Learn how the first fork creates processes and how the second fork executes in both to run prints.

Practise Operating systemsMore videos

The quiz

How many times does this C program print "hi"?

  1. 2
  2. 3
  3. 4
  4. 8
Show the answer

C. 4

Transcript

Yeh daily challenge question trap karega, two fork calls dekhkar log two bolte hain.

Screen par code dekho: main function pehle first fork call karta hai, fir second fork call karke newline ke sath hi print karta hai.

Execution flow dekho: hum ek process se start karte hain, pehla fork two processes banata hai, aur second fork four par prints chalata hai.

Ab sabse important part jo log miss karte hain: parent se cloned child banta hai, aur second fork actually both mein execute hota hai.

Is linear addition mein mat phansna, child bhi fork karta hai, execution both processes mein tree banakar total four prints generate karti hai.

Toh yeh C program screen par kitni baar hi print karega? Video ko abhi pause karo aur apna option A, B, C ya D chuno.

Correct answer hai C, 4. Kyunki first fork two processes banata hai aur second fork dono mein chalte hue total four processes banata hai.

Interview se pehle yeh process tree table save kar lo, aur aise core operating system concepts practice karne ke liye InternDoor daily challenge khelo.

More study videos

All videos
Learned it? See who is hiring

Engineering internships and entry-level jobs in India, newest first.