#include<iostream.h>
#include<conio.h>
class number
{
int x;
long ans;
public:
long factorial(int);
};
long number :: factorial(int a)
{
x=a;
ans=1;
while(a>0)
ans*=a--;
return ans;
}
int main()
{
clrscr();
int num;
cout<<"Enter the number to find factorial:";
cin>>num;
number a;
cout<<"The factorial is : "<<a.factorial(num);
getch();
return 0;
}
0 comments:
Post a Comment