#include<iostream>
using namespace std;
float factorial(int);
int main()
{
int k;
cout<<"enter the number ";
cin>>k;
cout<<"factorial of"<<k<<"is"<<factorial(k);
}
//function to evaluate the factorial
float factorial(int n)
{
if(n==0)
return(1);
else
return(n*factorial(n-1));
}
using namespace std;
float factorial(int);
int main()
{
int k;
cout<<"enter the number ";
cin>>k;
cout<<"factorial of"<<k<<"is"<<factorial(k);
}
//function to evaluate the factorial
float factorial(int n)
{
if(n==0)
return(1);
else
return(n*factorial(n-1));
}
No comments:
Post a Comment