GATE | GATE CS 2019 | Question 26
The following C program is executed on a Unix / Linux system:
#include <unistd.h> int main() { int i; for (i = 0; i < 10; i++) if (i % 2 == 0) fork(); return 0; } |
chevron_right
filter_none
The total number of child process created is __________ .
Note – This was Numerical Type question.
(A) 31
(B) 63
(C) 5
(D) 6
Answer: (A)
Explanation: Condition “if” will be satisfy for i = 0, 2, 4, 6, 8 only. So, “fork()” will call for 5 times.
Total number of processes created is,
= 2number of fork()
There is always only one parent process of these processes and remaining will be child processes.
Hence number of child process created is,
= 2number of fork() - 1 = 25 - 1 = 32 - 1 = 31
So, option (A) is correct.
Quiz of this Question
Recommended Posts:
- GATE | GATE CS 1999 | Question 36
- GATE | GATE CS Mock 2018 | Question 39
- Top 5 Topics for Each Section of GATE CS Syllabus
- How to prepare in Last 10 days to score high in GATE?
- Aptitude | GATE IT 2006 | Question 7
- Aptitude | GATE IT 2006 | Question 8
- GATE | GATE CS 2013 | Question 1
- GATE | GATE CS 2013 | Question 3
- GATE | GATE CS 2013 | Question 4
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 6
- GATE | GATE CS 2013 | Question 7
- GATE | GATE CS 2013 | Question 8
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65



