### Write a C program to find the factorial of a given integer using recursive function

In this article, we will write a C program to find the factorial of a given integer using a recursive function.

# ALGORITHM:

### main program

Step 1: start

Step 3: call sub program as f=fact(n)

Step 4: print f value

Step 5: stop

### Sub program:

Step 1: initialize the f

Step 2: if n= = 0 or n == 1 return 1 to main program if not goto step 3

Step 3: return n*fact(n-1) to main program

# Write a C program to find the factorial of a given integer using recursive function

``````#include <stdio.h>
#include <conio.h>

int fact(int);
void main()
{
int n, res;
clrscr();
printf("ENETR A NUMBER:\n");
scanf("%d", &n);
res = fact(n);
printf("THE FACTORIAL OF A GIVEN NUMBER IS -> %d", res);
getch();
}
int fact(int n)
{
int r;
if (n == 0)
return (1);
else
{
r = n* fact(n - 1);
return (r);
}
}
``````

INPUT:

``````ENTER A VALUE FOR n
5
``````

OUTPUT:

``THE FACTORIAL OF A GIVEN NUMBER IS -> 120``

# Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course