the loop works for all the subprograms of recursions.
if we call recursion 10 tymes.loop goes for 10 differt subprog....but ass i
is static so same value is used

On Wed, Aug 31, 2011 at 8:29 PM, aditya kumar
<aditya.kumar130...@gmail.com>wrote:

> but one u have pushed all elements on to the stack why do we again enetr
> the loop to decreement the value of i . i mean after all the recursion we
> need to return to the place from where funtion was being called . why to
> enter the loop again ??
>
>
> On Wed, Aug 31, 2011 at 8:26 PM, rahul sharma <rahul23111...@gmail.com>wrote:
>
>> no it will pus like
>> printf("d",i)
>> ....
>> .
>> .
>> .
>> ..
>> so onm
>>
>>
>> but i is static
>> latest value used
>> 9
>> 8
>> 7
>> instred of these printf are pushed
>>
>> On Aug 31, 7:53 pm, aditya kumar <aditya.kumar130...@gmail.com> wrote:
>> > @rahul : wen the values are pushed on to the stack they are like 9 , 8 ,
>> 7 ,
>> > till 0 so when they pop out shouldnt it be follwing the order 0 1 2 till
>> 9 .
>> > i realy dont know why the o/p is 0 -1 -2 and so on ??
>> >
>> > On Wed, Aug 31, 2011 at 8:18 PM, rahul sharma <rahul23111...@gmail.com
>> >wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > i thnink it works as follow:-
>> >
>> > > firstly
>> > > loop goes pushing into stack
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> > > printf("%d",i);
>> >
>> > > now i is 1
>> > > --i
>> > > means --1
>> > > i=0;
>> >
>> > > now all printf are poped printing --i
>> > > from 0;
>> >
>> > > m i ryt?????
>> >
>> > > On Aug 31, 7:40 pm, rahul sharma <rahul23111...@gmail.com> wrote:
>> > > > these two are same
>> >
>> > > > On Aug 31, 7:36 pm, ravi maggon <maggonr...@gmail.com> wrote:
>> >
>> > > > > I check out the code:
>> >
>> > > > > #include<stdio.h>
>> > > > > main()
>> > > > > {
>> > > > >     static int i=10;
>> > > > >     while(i>0)
>> > > > >     {
>> > > > >         --i;
>> > > > >         main();
>> > > > >         printf("%d",i);
>> > > > >     }
>> >
>> > > > > }
>> >
>> > > > > if you run this you get 0000000000 as output
>> >
>> > > > > but if you run this
>> >
>> > > > > #include<stdio.h>
>> > > > > main()
>> > > > > {
>> > > > >     static int i=10;
>> > > > >     while(i>0)
>> > > > >     {
>> > > > >         --i;
>> > > > >         main();
>> > > > >         printf("%d",i);
>> > > > >     }
>> >
>> > > > > }
>> >
>> > > > > You get 0-1-2-3-4-5-6-7-8 as output.
>> >
>> > > > > Whats the difference in these?
>> >
>> > > > > On Wed, Aug 31, 2011 at 7:52 PM, aditi garg <
>> aditi.garg.6...@gmail.com
>> > > >wrote:
>> >
>> > > > > > @abhishek: y till -8?
>> >
>> > > > > > On Wed, Aug 31, 2011 at 7:50 PM, vishal jain <
>> vishal.l...@gmail.com
>> > > >wrote:
>> >
>> > > > > >> I executed on linux machine..
>> >
>> > > > > >> I am gettign output
>> >
>> > > > > >> 0-1-2-3-4-5-6-7-8 :(
>> >
>> > > > > >> for code
>> > > > > >> int main()
>> >
>> > > > > >> {
>> > > > > >>     static int i=10;
>> > > > > >>     while(--i>0)
>> > > > > >>     {
>> > > > > >>          main();
>> > > > > >>          printf("%d",i);
>> > > > > >>     }
>> > > > > >> return 0;
>> > > > > >> }
>> >
>> > > > > >> On Wed, Aug 31, 2011 at 7:48 PM, Abhishek Mallick <
>> > > > > >> abhishek.mallick2...@gmail.com> wrote:
>> >
>> > > > > >>> The recursion will run 10 times printing nothing. Then ones it
>> > > returns
>> > > > > >>> on the 10th one. It will start printing from 0 to -8 (As i is
>> > > static).
>> >
>> > > > > >>> On Aug 31, 6:33 pm, ravi maggon <maggonr...@gmail.com> wrote:
>> > > > > >>> > Ans would be 0000000000, keep in mind that i is static
>> variable.
>> >
>> > > > > >>>  > On Wed, Aug 31, 2011 at 6:59 PM, rohit <
>> raman.u...@gmail.com>
>> > > wrote:
>> > > > > >>> > > 123456789
>> >
>> > > > > >>> > > --
>> > > > > >>> > > You received this message because you are subscribed to
>> the
>> > > Google
>> > > > > >>> Groups
>> > > > > >>> > > "Algorithm Geeks" group.
>> > > > > >>> > > To view this discussion on the web visit
>> > > > > >>> > >https://groups.google.com/d/msg/algogeeks/-/OsL6-Vp91qoJ.
>> > > > > >>> > > 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.
>> >
>> > > > > >>> > --
>> >
>> > > > > >>> > Regards
>> > > > > >>> > Ravi Maggon
>> > > > > >>> > Final Year, B.E. CSE
>> > > > > >>> > Thapar University
>> >
>> > > > > >>> --
>> > > > > >>> 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.
>> >
>> > > > > > --
>> > > > > > Aditi Garg
>> > > > > > Undergraduate Student
>> > > > > > Electronics & Communication Divison
>> > > > > > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>> > > > > > Sector 3, Dwarka
>> > > > > > New Delhi
>> >
>> > > > > >  --
>> > > > > > 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.
>> >
>> > > > > --
>> >
>> > > > > Regards
>> > > > > Ravi Maggon
>> > > > > Final Year, B.E. CSE
>> > > > > Thapar University
>> >
>> > > --
>> > > 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.
>>
>>
>  --
> 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