Your Ad Here

Tuesday, February 12, 2008

Factorial

/* C++ program for calculating factorial of a number entered by the user */

# include < iostream.h>
# include < conio.h>
void fact(int);

void main()
{
clrscr();
int n;
cout < < "Enter limit : ";
cin>>n;
fact(n);
getch();
}
void fact(int x)
{
char a;
int i=1;
for(int j=1;j< =x;j++)
{
i*=j;
}
cout< < "Answer = "< < i< < endl;
cout< < "Want to continue ( y )/or press any key to continue ";
cin>>a;
if(a=='y')
{
main();
}
else
{
cout< < "Good Bye ";
}
getch();
}

1 comment:

jonathan_lui said...

can you help me on my project?please please

Your Ad Here