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 <[email protected]> wrote:
> these two are same
>
> On Aug 31, 7:36 pm, ravi maggon <[email protected]> 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
> > <[email protected]>wrote:
>
> > > @abhishek: y till -8?
>
> > > On Wed, Aug 31, 2011 at 7:50 PM, vishal jain <[email protected]>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 <
> > >> [email protected]> 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 <[email protected]> wrote:
> > >>> > Ans would be 0000000000, keep in mind that i is static variable.
>
> > >>> > On Wed, Aug 31, 2011 at 6:59 PM, rohit <[email protected]> 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 [email protected].
> > >>> > > To unsubscribe from this group, send email to
> > >>> > > [email protected].
> > >>> > > 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 [email protected].
> > >>> To unsubscribe from this group, send email to
> > >>> [email protected].
> > >>> 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 [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected].
> > >> 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 [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.