Thursday, 21 July 2011

PROGRAM to find the factorial using class in C++

Do you like this post?
#include
#include
class factorial
{
int num;
public:
void getinfo()
{
cout<<"\n Enter the number for which the factorial is to be found : "; cin>>num;
}
void facto()
{
int i,fact=1;
if(num==0||num==1)
cout<<"\n Factorial of "< else
{
for(i=1;i<=num;i++)
{fact=fact*i;
}
cout<<"\n Factorial of "< }
}
};
void main()
{
factorial f1;
clrscr();
f1.getinfo();
f1.facto();
getch();
}

No comments:

Post a Comment