recursive function in c

 #include<stdio.h>

int factorial (int number)
{if ( number == 0 || number ==1)

    return 1;


    else
    
        return ( number * factorial ( number -1));

    
    

}
int main(int argcchar const *argv[])
     int num;
    
    printf(" enter the num you want to print factorial \n");
    scanf("%d",&num);
    printf(" the factorial of %d is %d "num , factorial(num));
    return 0;
}


The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called as recursive function. Using recursive algorithm, certain problems can be solved quite easily.























































Comments