### Recursive Function in C

Write a program to calculate factorial of a given integer number. Use recursive function

1. #include
main()
{
int a;
scanf("%d",&a);
fact(a);
printf("\nFactorial of given integer number :");
printf("%d\n",fact(a));
}

int fact(int p)
{
int i;
int sum=1;
for (i=1;i<=p;i++)
{
sum*=i;
}
return sum;
}

2. #include
#include
long int find_factorial(long int);
int main()
{
int num;
long int n;
printf("\n Enter number for find_factorial:");
scanf("\n%d",&num);
if(num<0)
printf("\n Negative number are not allowed");
else
{
n=find_factorial(num);
printf("\n%d! =%1d",num,n);
}
return 0;

}

{
return 1;
else

}

3. #include
#include
long int find_factorial(long int shuvo);
int main()
{
long int shohan,salman;
printf("Enter number for find factorial:");
scanf("%d",&shohan);
salman=find_factorial(shohan);
printf("\n Factorial is %d",salman);
getch();
return 0;
}

long int find_factorial(long int shuvo)
{
if(shuvo==0)
return 0;
else if(shuvo==1)
return 1;
else
return(shuvo*find_factorial(shuvo-1));

}

4. #include
#include
long int find_factorial(long int);
int main()
{
int num;
long int n;
printf("\n Enter number for find_factorial:");
scanf("\n%d",&num);
if(num<0)
printf("\n Negative number are not allowed");
else
{
n=find_factorial(num);
printf("\n%d! =%1d",num,n);
}
eturn 0;
}
long int find_factorial(long int mennath)
{
if(mennath==0)
return 1;
else
return(mennath*find_factorial(mennath-1));
}

5. #include
int fact(int n);
main()
{
int n,result;
printf("enter the number for find factorial:");
scanf("%d",&n);
result=fact(n);
}
int fact(int p)
{
if(p<=1)
return(1);
else
return(p*fact(p-1));
}

6. ID : 201620195
https://www.dropbox.com/s/zbju2mzftbsdf4v/05.cpp?dl=0

7. This comment has been removed by the author.

8. MD USUF MIA
ID 201610456

9. ID:201520552

10. ID:201520552

11. Summer 2017
ID#201610042

15. ID:201610254

#include
using namespace std;

class fact
{
public:
int n,f;

fact()
{
cout<<"Enter an integer to find factorial:";
cin>>n;

if(n<0)
cout<<"Negative integer are not allowed";

}
int factorial(int n)
{
if(n==0||n==1)
return 1;
else
return (n*factorial(n-1));
}

};

int main()
{

fact obj;
cout<<"Factorial of given number:"<<obj.factorial(obj.n)<<endl;

return 0;
}