Question 9
What could be the possible output of the following program?
#include <stdio.h>#include <stdlib.h>
int main() { int x = 10, pid; pid = fork(); if (pid == 0) { x += 5; printf("Child 1: %d\n", x); } else { x += 10; printf("Parent 1: %d\n", x); pid = fork(); if (pid == 0) { x += 20; printf("Child 2: %d\n", x); } else { x += 30; printf("Parent 2: %d\n", x); } } return 0;}Parent 1: 20
Child 1: 15
Child 2: 30
Parent 2: 50Child 1: 25
Parent 1: 20
Parent 2: 50
Child 2: 30Parent 1: 20
Parent 2: 50
Child 1: 20
Child 2: 50Child 1: 15
Parent 1: 25
Parent 2: 50
Child 2: 35