Gate2019 cs Q27

0. The following C program is executed on a Unix/Linux system:

 int main()
 {
 int i;
 for (i=0; i<10; i++)
 if (i%2 == 0) fork();
 return 0;
 }
 The total number of child processes created is ________.

Note – Numerical Type question

  • Option : 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
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *