Thread: need help with recursive functions

1. need help with recursive functions

Hi all .I need some one to explain what and how recursive functions work...

Thanks lot

2. Basically, a recursive function is a function which would call itself until a certain condition is TRUE.

Eg.
Code:
```unsigned long  factorial(int number)
{
return (number < 2) ? 1 : number * factorial(number - 1);
}```
Notice that if number is not less than 2, then number is multiplied with the return value of another call to factorial().

3. And the obvious.

4. I will if you explain how the enums work around this joint, sir

What's UP!
RECURSION--is the ability of a function to cal itslef, either directly or indirectly.
EX>>>.
#include<stdio.h>

void count_down(int n); /*function prototype*/

int main(void)
{
count_down(10); /*recursive function call itself over and over again until it reaces 0*/
return 0; /*program completed sucessfully*/
}

void count_down(int n) /*function definition*/
{
if (n) {
printf("%d ! ", n);
count_down(n-1); /*recursive function that counts down to 0 then prints BLAST OFF!*/
}
else
printf("\nBLAST OFF\n");
}

Hope this example helps so complie, run it to see, huh!?!?