Program using a recursive function to find factorial of no.

float fact(int);
void main()
{
int n;
float f;
printf("Enter the no");
scanf("%d",&n);
f=fact(n);
printf("Factorial=%f",f);
getch();
}
float fact(int x)
{
float f1;
if(x==1_
{
return;
}
else
{
f1=x*fact(x--);
}
return(f1);
}

No comments:

Post a Comment