#include <iostream>
#include <conio.h>
class copy
{
int var,fact;
public:
copy(int temp)
{
var = temp;
}
double calculate()
{
fact=1;
for(int i=1;i<=var;i++)
{
fact = fact * i;
}
return fact;
}
};
int main()
{
int n;
cout<<"\nEnter the Number : ";
cin>>n;
copy obj(n);
copy cpy=obj;
cout<<"\n"<<n<<" Factorial is:"<<obj.calculate();
cout<<"\n"<<n<<" Factorial is:"<<cpy.calculate();
int main()
{
int n;
cout<<"\nEnter the Number : ";
cin>>n;
copy obj(n);
copy cpy=obj;
cout<<"\n"<<n<<" Factorial is:"<<obj.calculate();
cout<<"\n"<<n<<" Factorial is:"<<cpy.calculate();
system ("pause");
return 0;
}
0 comments:
Post a Comment