GATE CS 2024, set 1 · Question 57 · Operating System · Numerical answer (NAT) · 2 marks · no negative marks

Consider the following code snippet using the fork() and wait() system calls. Assume that the code compiles and runs correctly, and that the system calls run successfully without any errors.
int x = 3; while(x > 0) { fork(); printf("hello"); wait(NULL); x--; }
The total number of times the printf statement is executed is ______

Answer

Answer 14

Answer from the official GATE CS 2024 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes