title: What is the difference between fork()!=0 and !fork() in process creation
body: <p>Currently, I am doing some exercises on operating system based on UNIX. I have used the fork() system call to create a child process and the code snippet is as follows :</p>
  
  <pre><code>if(!fork())
  {
     printf("I am parent process.\n");
  }
   else
     printf("I am child process.\n");
  </code></pre>
  
  <p>And this program first executes the child process and then parent process.</p>
  
  <p>But, when I replace <code>if(!fork()) by if(fork()!=0</code>) then the parent block and then child block executes.Here my question is - does the result should be the same in both cases or there is some reason behind this? Thanks in advance!!</p>