546 views
2 votes
2 votes
the output of the following program is

Void main()

{

Int a= 10;

If (fork()==0)

a++;

Print("%d", a);

}

 

0,10

10,10

11,10

11,11

1 Answer

Best answer
2 votes
2 votes
When ever fork system call is executed parent and child have create there local copy of variable, so both will have value a=10, now when child copy is executed it will increase value of it, but this change is within child's own address space so answer will be

Either 10,11 or 11,10 it depends if Who will execute first

Since only one option match this final Answer is 11,10
selected by

Related questions

1 votes
1 votes
2 answers
2
Warrior asked Nov 10, 2018
1,358 views
0 votes
0 votes
0 answers
3
eyeamgj asked Aug 6, 2018
258 views
https://gateoverflow.in/765/gate2005-72wwhile answering this question how we are concluding that we need to take logical address part not physical address part????