Skip to content
Related Articles

Related Articles

Improve Article

GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 26

  • Last Updated : 06 Nov, 2020

A process executes the following code:




#include <stdio.h> 
#include <unistd.h>  
  
int main() 
    if (fork() && (!fork())) { 
        if (fork() || fork()) { 
            fork(); 
        
    
    int i=1;
    printf("i++");  
    return 0; 

Output of the above program is

(A) i++i++i++i++i++i++i++
(B) 1 2 3 4 5
(C) 1 1 1 1 1
(D) None of these


Answer: (A)

Explanation: Printed output:

i++i++i++i++i++i++i++




#include <stdio.h> 
#include <unistd.h>  
  
int main() 
    if (fork() && (!fork())) { 
        if (fork() || fork()) { 
            fork(); 
        
    
    int i=1;
    printf("i++");  
    return 0; 

Option (A) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.




My Personal Notes arrow_drop_up
Recommended Articles
Page :