What is the output of the following program
#include<stdio.h>
main()
{
int i=0;
fork();
printf("%d",i++);
fork();
printf("%d",i++);
fork();
wait();
}
Answer Posted / srikanth
print order cannot be predicted.Total 8 process(including
main) first process prints 0,1
the first child prints 0,1 and the other 2 child/grand child
process print 1's (two 1s). The other four child/grand child
process wont print anything (created after printf)
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is action and transformation in spark?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What is size of union in c?
What is sizeof array in c?
How does placing some code lines between the comment symbol help in debugging the code?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
Explain what are run-time errors?
Place the #include statement must be written in the program?
What is meant by type casting?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
which is conditional construct a) if statement b) switch statement c) while/for d) goto
What are types of functions?
What are inbuilt functions in c?
What does main () mean in c?
Describe newline escape sequence with a sample program?