freelanceprogrammers.org Forum Index » C
C PUZZLE!
Joined: 29 Jul 2003
Posts: 1
C PUZZLE!
Hi all,
how does this pgm work??
voidf(char *)main(){f("123");}voidf(char a[]){if(a[1] == ` `) return ;f(a+1);f(a+1);printf("%c",a[1]);}
cheers,
P
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
Joined: 19 Jul 2003
Posts: 29
C PUZZLE!
Do a dry-run and you`ll get the answer as well as
understand how it works. It uses recursion, in case
you didn`t know that.
BTW, does it produce an output "22221"? I did a quick
dry-run just now (and used little bit speculation :-).
I might be wrong too.
Regards,
Shantanu
--- polka dot <purplepolka_81@...> wrote:
> Hi all,
>
> how does this pgm work??
>
> voidf(char *)
> main()
> {
> f("123");
> }
> voidf(char a[])
> {
> if(a[1] == ` `) return ;
> f(a+1);
> f(a+1);
> printf("%c",a[1]);
> }
>
> cheers,
> P
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







