Tuesday, August 3, 2010

C Code To find the Factorial of a Number(Recursive function Call)

/***********Factorial of a Number ( recursive C program) ************/
int fact(int n)
{
    int fact;
    if(n==1 || n==0)
       return(1);
    else
        fact = n * fact(n-1);
   return(fact);
}
/* Implementing code in recursive manner is avoided in most cases as it reduces coding complexity and increases the overhead as lot of stacks get created as the function gets called again and again recursively */

No comments:

counter