#include<iostream>
using namespace std;
int fact (int num);
int main () {
cout<<"Enter a number"<<endl;
int number;
cin>>number;
cout<<"Displaying number: "<<number<<endl;
cout<<"Calculating Factorial for the number"<<endl;
int fact;
fact = fact(number);
return 0;
}
int fact (int num)
{
if(num==1)
{
return num;
}
else
{
return num * fact(num -1);
}
}
This program gives the following error:
fact cannot be used as a function.
could someone help me on this issue