Assuming that the system call fork() never fails, consider the following C…

PYQ UGC NET 2020

Assuming that the system call fork() never fails, consider the following C program 𝑃1 and 𝑃2 executed on a UNIX/Linux system:

/* P1 */

int main() {

fork();

fork();

fork();

printf("Happy\n");

}

/* P2 */

int main() {

fork();

printf("Happy\n");

fork();

printf("Happy\n");

fork();

printf("Happy\n");

}

Statement 𝐼: 𝑃1 displays “Happy” 8 times

Statement 𝐼𝐼: 𝑃2 displays “Happy” 12 times

In the light of the above statements, choose the correct answer from the options given below

  1. A.

    Both Statement 𝐼 and Statement 𝐼𝐼 are true

  2. B.

    Both Statement 𝐼 and Statement 𝐼𝐼 are false

  3. C.

    Statement 𝐼 is correct but Statement 𝐼𝐼 is false

  4. D.

    Statement 𝐼 is incorrect but Statement 𝐼𝐼 is true

Attempted by 387 students.

Sign up free to check your answer

Sign up free

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…