Program:
#include<stdio.h> void main() { int cpid = fork(); if(cpid == 0) { printf("\n\n Child is running:\n\n ParentID: %d \n It's ID: %d \n\n",getppid(),getpid()); } else if(cpid > 0) { printf("\n\n Parent is Running:\n\n ParentID: %d \n It's ID: %d \n\n",getppid(),getpid()); } else { printf("Error"); } }
Output: