I was going through the example program for semaphores in Beej's Guide to Unix IPC.
The example program contains the following semaphore initialization code. I am only posting a snippet from it that is relevant to the question. To see the complete code, visit the link I have provided above.
/*
...