sample code for fork system call in c:
What is the output of below C program?
printf("Hello world \n");
it prints hello world
it prints hello world thrice
it prints hello world twice
doesn't print any thing
fork() creates a new process, and copies the code of parent process into child process. But the executing continues in both the process from the line of fork() command. so what ever the instructions written after fork() , they will be executed twice one in parent process and other in child process. so it prints hello world twice.
Back To Top