Monday, May 6, 2013

Program To Find Factorial Of Any Number


This is a simple program with good logic.Factorial  of any number N can be found by n*(n-1)*(n-2)*....(1)

#include<iostream.h>
#include<conio.h>
void main()
{
int fact=1,i;
double num;
cout<<"enter the number of which you want factorial\n";
cin>>num;
for(i=num;i>0;i--){
fact=fact*num;
num--;
}
cout<<"factorial is\n"<<fact;

getch();
}


Output:
  

No comments:

Post a Comment