Sunday, December 6, 2009
FACTORIAL
,
Author: Raviteja
|
Filed Under:
c++
|
#include "iostream.h"
#include "conio.h"
class fac
{
private:
long n;
public:
void accept ()
{
cout << "Welcome to finding a factorial of a no.\n\n";
cout << "Enter a number( 1 to 31): ";
cin >> n;
}
void cal ();
};
void fac :: cal ()
{
cout << "\nFactorial of " << n << " is: ";
for (int i=n-1; i>0; i--)
{
n *= i;
}
cout << n;
}
void main ()
{
clrscr ();
fac F;
F.accept ();
F.cal ();
getch ();
}
Get the executable ( .exe ) file for this program..
Download
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment