Program factorial using recursion
Tuesday, 22 November 2016
Programming in 'C'
Factorial of a number using recursion:-
#include<stdio.h>
#include<conio.h>
int recu (int x);
void main()
{
clrscr();
int n, fact;
printf ("Enter The Number:");
scanf ("%d",&n);
fact=recu(n);
printf ("%d",fact);
getch();
}
int recu (intx)
{
intf;
if(x==1)
return 1;
else
{
f=x*recu(x-1);
}
return(f);
}
Output:-
Enter The Number: 7
5040