how to build for and while loops using a recursion?
Printable View
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);
}