# Number of child

131 views
Can Anyone Explain clearly

process

{

fork();

fork();

fork();

}

what are the number of childs?

7.

First fork() will generate 1 children. Total number of process = 1 child (C1) + 1 parent (P) = 2.

Second fork() will generate 1 more process in C1 (C2) and one more process in P (C3), Total number of child processes at this stage = 3.

Similarly, 4 more child processes will be generated after calling third fork().

So, overall 8 processes will be there, 1 parent and 7 children. For more information, you can refer to the link provided to you in response to your another similar question .

selected

Bcz when we execute fork() command then a child process is created and then the next instruction following this fork() command will be executed by both parent as well as by the child process.

First fork() will generate 1 children. Total number of process = 1 child (C1) + 1 parent (P) = 2.

Second fork() will generate 1 more process in C1 (C2) and one more process in P (C3), Total number of child processes at this stage = 3.

Similarly, 4 more child processes will be generated after calling third fork().

So, overall 8 processes will be there, 1 parent and 7 children.

## Related questions

1
490 views
In a Binary Tree with N nodes,every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child? A) 0 B) 1 C) (n-1)/2 D) (n-1)