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
Article Tags :
Recommended Articles