0 votes 0 votes #include<stdio.h> void main () { int a=10; if((fork()==0)) a++; printf("%d\n",a); if((fork()==0)) a++; printf("%d\n",a); } Please provide complete flow of above code execution along with output explanation. ARUN KUMAR 3 asked Sep 20, 2018 ARUN KUMAR 3 213 views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply smsubham commented Sep 20, 2018 reply Follow Share Actual order in which output is printed depends on scheduling. 2 votes 2 votes ARUN KUMAR 3 commented Sep 20, 2018 reply Follow Share but in output: 3 times (10), 4 times (11), and once 12 . 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share @ARUN KUMAR 3 1st printf statement executes two times only i) parent(P1) print = 10 ii) parent(P2) print = 11 2nd printf statement executes four times only I:- i) parent(P1) print = 10 ii) child (P3) print = 11 II:- i) parent(P2) print = 11 i) child(P4) print = 12 Total prints = 6 but not 8 that is wrong, what the process given by smsubham is absolutely right. 1 votes 1 votes Please log in or register to add a comment.