1,280 views
2 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 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
Position:
Show:

Related questions

1 1 vote
2 2 answers
2.4k
2.4k views
Warrior asked Nov 10, 2018
2,354 views
0 0 votes
0 0 answers
558
558 views
eyeamgj asked Aug 6, 2018
558 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????
11 11 votes
5 answers 5 answers
2.6k
2.6k views
Kaluti asked Aug 20, 2017
2,612 views
find total no of processes i am getting 29 as answer as all will be child process except one parent process plz explain how answer is 24 here i am very confused in such q...