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 the value of uninitialized variable in c?
What is meant by 'bit masking'?
Is stack a keyword in c?
Do you know the difference between malloc() and calloc() function?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
What is sizeof c?
What are the rules for the identifier?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What does the characters “r” and “w” mean when writing programs that will make use of files?
Can a file other than a .h file be included with #include?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
Explain how do you list files in a directory?
2) Write a program that will help Air Traffic Control for an airport to view the sequence of flights ready for take-off. The airport can accommodate 10 flights waiting for take-off at any point in time. Each flight has a unique 3 digit numeric identifier. Each time a flight takes-off, Air Traffic Control adds a flight to the waitlist. Each time a flight is added to the waitlist, the list of flights waiting to take-off must be displayed. When a flight is cleared for take-off, Air Traffic Control removes the flight from the waitlist. Each time a flight takes-off, the list of flights waiting to take-off must be displayed. Sequence of take-off is the sequence of addition to the waitlist