how to build for and while loops using a recursion?
how to build for and while loops using a recursion?
Why would you want to do this, though? It's much simpler with loops, and you won't need to worry about stack overflow.Code:void countdown(int n) { if (n == 0) return; printf("%d\n", n); countdown(n - 1); }
thanks
Code:void LoopFor ( int y, int n){ int x; for (x=y; x<=n; x++) LoopFor (x, y, n); } void main (void) { LoopFor (0, 100); }
Last edited by sergioms; 01-06-2009 at 04:26 PM. Reason: ehuehehhu =p
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.