Saturday, February 14, 2015

C Program to calculate Factorial of any number


#include<iostream.h>
#include<conio.h>
void main()
{     
  clrscr();
unsigned long i,fac,n;
cout<<"Enter Number: ";
cin>>n;


for(i=1,fac=1;i<=n;++i)
{
fac=i*fac;
}
cout<<"Factorial 0f "<<n<<" is: "<<fac;
getch();
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.