when parent process come across fork(),it creates a child processes.
in the multiprogramming environment,there is no order of execution defined.
a child process can be executed first or a parent process can be executed first.
so,the answer could be either 10 and 11
or 11 and 10.
if the question is msq type,then select both 10 and 11 ,11 and 10.
is my intution correct for following?
what is the value printed by child process ?
will the “if condition” will be evaluated by child process or
child process directly executes line 3?
main()
{
1. int a = 10;
2. if(fork()) == 5)) //not fork()==0
3. a++;
4. printf("%d\n",a);
}
since,a single line is converted into multiple machine level instructions,
so, the if condition will be evaluated and “if condition” fails.so,the value printed by child process is 10.