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
How many levels of pointers can you have?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is a macro, and explain how do you use it?
Can we use visual studio for c?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
What is structure in c language?
What is union and structure in c?
What is the difference between char array and char pointer?
Write a program to identify if a given binary tree is balanced or not.
Is c compiled or interpreted?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
using only #include
Are there constructors in c?
What is context in c?
Are the variables argc and argv are always local to main?