2,204 views
6 votes
6 votes

Consider the code below and choose the correct option:

main(){
    int child = fork();
    int c = 5;
    if(child == 0)
        c += 5;
    else{
        child = fork();
        c += 10;
        if(child)
            c += 5;
    }
}

(A) Total 3 processes are there with value of variable c as 5, 10, and 15.
(B) Total 3 processes are there with value of variable c as 10, 15, and 20.
(C) Total 3 processes are there with value of variable c as 10, 15, and 15.
(D) Total 4 processes are there with value of variable c as 10, 15, 15, and 20.

1 Answer

Best answer
9 votes
9 votes

 Total 3 processes with values of c as 10 , 15 , 20.

selected by

Related questions

2 votes
2 votes
3 answers
3
Philosophical_Virus asked Dec 10, 2023
993 views
Int main (){fork();printf("a");fork();printf("b");return 0;}How many distinct outputs are possible of above code? And also give outputs
3 votes
3 votes
1 answer
4
24aaaa23 asked Oct 1, 2023
875 views
Consider the following code segment :int main (void) { for (int i=2; i<=5; i++) { fork( ); }printf (“GOCLASSES”);How many times “GOCLASSES” is printed by the ab...