0
factorial_c++ (unknown error
I'm trying to write a code to find factorial in C++ https://code.sololearn.com/cwa12lCWemN2/?ref=app
2 Answers
+ 2
Just some simple hitches, you defined variable i, which was unused, again returning () to finish the int main function is not a good practise. You need to terminate the int main by returning 0
#include <iostream>
using namespace std;
long int fact(long int);
int main() {
int n;
cout<<"Enter the number"<<endl;
cin>>n;
cout<<"factorial of "<<n<<" = "<<fact(n);
return 0;
}
long int fact(long int m)
{
if(m==0)
{return(1);}
else
{return(m*fact(m-1));}
}
here your code editted
happy coding đ keep coding đ