All mock tests are FREE till 31 December — register to save your progress

Assuming that the system call fork() never fails, consider the following C programs P1 and P2 executed on a UNIX/Linux system.
P1P2
int main() {
  fork();
  fork();
  fork();
  printf("Happy\n");
}
int main() {
  fork();
  printf("Happy\n");
  fork();
  printf("Happy\n");
  fork();
  printf("Happy\n");
}
Statement I: P1 displays "Happy" 8 times.
Statement II: P2 displays "Happy" 12 times.
In light of the above statements, choose the most appropriate answer.

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. (C) Statement I is correct but Statement II is false

More System Software and Operating System questions