try this : #include<unistd.h> > #include<stdio.h> > #include<stdlib.h> > > int main() > { > int i=0,count=0; > pid_t pid; > for( ;i<10;i++,count++) > { > pid=fork(); > i++; > //printf("%d ",pid); > } > printf("count is=%d",count);
> } > > as loop works only five times but each time fork is being invoked,hence > creating a child process. > so count will be printed 32 times (2^(no. of fork invoked)). i hope this helps. > * > * > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- best wishes!! Vaibhav Shukla DU-MCA -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.