1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<stdio.h>
#include<conio.h>
int factf(int);
void main()
{
int a, fact;
printf("enter a number to find its factorial:- ");
scanf("%d",&a);
fact=factf(a);
printf("Factorial is %d",fact);
getche();
}
int factf(int x)
{
int y=1;
if(x !=0)
y=x*factf(x-1);
return(y);
}
|
Recursive function is that function that falls it self. We should set certain conditions if not the program will be of infinite loop.
0 comments:
Post a Comment