FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!

The Horrors of C




[to be recycled]



3 blog comments below

I don't see any recursive in your example or even a loop.

A loop is like this:
Code:
int function(int i=0)
{
for(; i<10;)
    {
       i++;
       //anything goes here
     }
return i;
}


A recursive function version would look like this:
Code:
int function(int i=0)
{
if(i<10)
{
i++;
function(i);
}
else
{
return i;
}
}


It should return 10. A recursive function is calling the function within the function.
Hopefully, I'm not making crap out of myself. Laughing
loremar on Sat Sep 03, 2011 7:57 pm
I like like 'C'. Never used the 'recursion' function however. I have programmed in different machine assembly languages and various Basic, Pascal (similar to 'C') and Fortran.
standready on Sat Sep 03, 2011 10:08 pm
Lorimar is correct. Recursion is 'self calling' - the output becomes the input for the next 'loop'.
Your code contains no recursive section at all.
Bikerman on Sat Sep 03, 2011 11:02 pm



FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.