its seem to me that output buffer is not flushing ......to do so you need
to add "\n" while printing hello i.e
 printf("Hello\n");

it was working for you when the else {} part was un-commented  because you
are using "\n" in this statement
//printf(" %d -> %d \n" , tmp[i], count); -- if you remove "\n" from here
then same problem will be reproduced


On Mon, Oct 29, 2012 at 12:47 PM, Rahul Kumar Patle <
patlerahulku...@gmail.com> wrote:

> can anyone explain the reason for weird output producing by this code..
> it is giving output hello many time >30 but as code's logic it should
> print only 9 time
> it runs correctly when i comment out statements inside else{}
> thanks in advance
>
> #include<stdio.h>
> #include<stdlib.h>
> int count = 0;
> main()
> {
>     int tmp[10] , i;
>     int n = 0;
>     for(i=0;i<9;i++)
>     {
>         tmp[i]=fork();
>         if(tmp[i]>0)
>             break;
>         else
>         {
>             //count++;
>             printf("Hello");
>             //printf(" %d -> %d \n" , tmp[i], count);
>         }
>     }
> }
>
> --
> Thanks and Regards:
> Rahul Kumar Patle
> M.Tech, School of Information Technology
> Indian Institute of Technology, Kharagpur-721302, 
> India<http://www.iitkgp.ac.in/>
> Mobile No: +91-8798049298, +91-9424738542
> Alternate Email: rahulkumarpa...@hotmail.com
> [image: 
> Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
> [image: Twitter] <https://twitter.com/rahulkumarpatle>
> <https://www.facebook.com/rkpatle>
>
>  --
> 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.
>

-- 
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.

Reply via email to