UGC NET CS 2020System Software and Operating System › Basics of Operating SystemsVerified
UGC NET CS 2020 PYQ: Assuming that the system call $\text{fork}()$ never fails, consider the following C program $P1$ and $P2$…
Assuming that the system call $\text{fork}()$ never fails, consider the following C program $P1$ and $P2$ executed on a UNIX/Linux system:
$\begin{array}{|ll|ll|} \hline & /*P1*/ & &/*P2*/ \\ \text{int} & \text{main}() \{ & \text{int} & \text{main} () \{ \\ & \text{fork} (); & & \text{fork();} \\ & \text{fork}(); && \text{printf(“Happy ”)}; \\ & \text{fork}(); & & \text{fork()}; \\ & \text{printf(“Happy ”);} & &\text{printf(“Happy ”);} \\ \} & & & \text{fork()};\\ && & \text{printf(“Happy ”);} \\ && \} \\ \hline \end{array}$
Statement $I$: $P1$ displays “Happy” 8 times
Statement $II$: $P2$ displays “Happy” 12 times
In the light of the above statements, choose the correct answer from the options given below
- ABoth Statement $I$ and Statement $II$ are true
- BBoth Statement $I$ and Statement $II$ are false
- CStatement $I$ is correct but Statement $II$ is falseCorrect answer
- DStatement $I$ is incorrect but Statement $II$ is true
Answer
(C) Statement $I$ is correct but Statement $II$ is false
Approach
Reviewed by UGC IQ Editorial Team.