Social Icons

Saturday, 15 February 2014

Program to calculate Factorial of a number

#include<iostream.h>
#include<conio.h>
void main()
{    
clrscr();
unsigned long i,fact,n;
cout<<"\n Enter a Number : ";
cin>>n;
fact=1;
for(i=1;i<=n;++i)
{
fact=i*fact;
}
cout<<"\n\tFactorial of "<<n<<" is : "<<fact;
getch();
}


                                                      Output

No comments:

Post a Comment