Sunday, 7 December 2014

C++ program to get factorial of a given number

#include<constream.h>
long int fact();
void main()
{
 clrscr();
 long int y;
 y=fact();
 cout<<"fact of n:"<<y;
 getch();
}
long int fact()
{
       long int fact=1,n,i;
 cout<<"\nenter n:";
 cin>>n;
 for(i=1;i<=n;i++)
 {
  fact=fact*i;
 }
 return fact;
}