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

Thanks lot

Printable View

- 07-18-2002datainjectorneed help with recursive functions
Hi all .I need some one to explain what and how recursive functions work...

Thanks lot - 07-18-2002The Dog
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);

}

- 07-18-2002Hammer
And the obvious.

- 07-18-2002correlcjI 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!?!?