Â
#include <stdio.h>
using namespace std;
class Fact
{
public:
int n, fact = 1;
Fact(int num)
{
n = num;
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
}
Fact(const Fact &f1)
{
fact = f1.fact;
}
void showFact()
{
cout << "The factorial is " << fact;
}
};
int main()
{
int num, res;
cout << "Enter a number: ";
cin >> num;
Fact f1(num);
Fact f2(f1);
f2.showFact();
return 0;
}
//..........Coded by SAHIL SHAIKH
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP