Question: In many programs and man pages of Linux, I have seen code using `fork()`. Why do we need to use `fork()` and what is its purpose?

Answer: 
fork() is basically used to create a child process for the process in which you are calling this function. Whenever you call a fork(), it returns a zero for the child id.  

```
pid=fork()
if pid==0
//this is the child process
else if pid!=0
//this is the parent process

```

by this you can provide different actions for the parent and the child and make use of multithreading feature.
fork() will create a new child process identical to the parent. So everything you run in the code after that will be run by both processes — very useful if you have for instance a server, and you want to handle multiple requests.