Sunday, 24 July 2011

PROGRAM IN C++ to find the factorial using class

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();
}

4 comments:

  1. Factorial Program in C++

    in c++ you can easily write Factorial of any number, it is the product of an integer and all the integers below it for example factorial of 5 is
    5! = 5 * 4 * 3 * 2 * 1 = 120. factorial program in c++ is very simple and easy.

    ReplyDelete
  2. Factorial Program in C++

    in c++ you can easily write Factorial of any number, it is the product of an integer and all the integers below it for example factorial of 5 is
    5! = 5 * 4 * 3 * 2 * 1 = 120. factorial program in c++ is very simple and easy.

    ReplyDelete