Chapter:

Recursive-program-in-c

Program to find Factorial of a Number using Recursion

Below is a program for finding factorial of a given number using recursion.

Source code:

#include

// declaring the function

int fact(int);


int main()

{

    int num, f;

    printf("\n\nEnter a number: ");

    scanf("%d", &num);

    f= fact(num);

    printf("\n\nFactorial of  %d is %d\n\n", num, f);

     return 0;

}


int fact(int aj)

{

    if(aj==1 || aj==0)

        return 1;

    else

        return (aj*fact(aj-1));

}

Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-