GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2024 set1

GATE 2024 set1 · CS · NAT · 2 marks · Operating System › Processes & Threads

GATE 2024 set1 Computer Science and Information Technology question: Consider the following code snippet using the fork() and wait() system calls. Assume…

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 _______

Show answer

Official answer: 14

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion