79567067

Date: 2025-04-10 15:37:41
Score: 1
Natty:
Report link

Q3) Draw Fork Trees for the following Codes also predict what would be the output.

Part a)

#include <stdio.h>

#include <unistd.h>

int main()

{

if (fork() || fork())

fork();

printf("1 ");

return 0;

}

Part b)

#include <stdio.h>

#include <unistd.h>

int main()

{

if (fork()) {

if (!fork()) {

fork();

printf("1 ");

}

else {

printf("2 ");

}

}

else {

printf("3 ");

}

printf("4 ");

return 0;

}

Part C)

#include <stdio.h>

#include <unistd.h>

int main()

{

if (fork() || fork())

fork();

printf("1 ");

return 0;

}

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Abiha Irfan