What is the output of the following program? main( ) {                 int a = 10;                 if ((fork ( ) == 0))                 a++;                 printf (“%d\n”, a ); }

What is the output of the following program? main( ) {                 int a = 10;                 if ((fork ( ) == 0))                 a++;                 printf (“%d\n”, a ); } Correct Answer 10 and 11

fork is an operation using fork a process creates a copy of itself.

Here parent process will print 10 and child process will print 11.

Related Questions

Comment on the following 2 C programs.
#include  //Program 1int main(){ int a; int b; int c;}#include  //Program 2int main(){ int a; { int b; } { int c; }}
Comment on the output of the following C code.
#include int main(){ int a = 1; switch (a) case 1: printf("%d", a); case 2: printf("%d", a); case 3: printf("%d", a); default: printf("%d", a);}
What is the difference between the following 2 C codes?
#include  //Program 1int main(){ int d, a = 1, b = 2; d = a++ + ++b; printf("%d %d %d", d, a, b);}

#include  //Program 2int main(){ int d, a = 1, b = 2; d = a++ +++b; printf("%d %d %d", d, a, b);}