This program is used for calculating factorials.
Because of the limitation of bits of machines,!13 was calculated in advance and got printed it in two parts.
Use long double instead of long int so that can get answer in powers of e and calculate larger factorials, can you please help me with this?
#include
using namespace std;
void main()
{
int j,n,z,x=1;
long int p=1;
while(x++<=13)
{
cout<<"Enter The number: ";
cin>>n;
if(n<=12 && n>=0)
{
if(n==0)
{
p=1;
}
else if(n<=12 && n>=0)
{
for(j=n;j>=1;j--)
{
p=p*j ;
}
}
cout<<"Factorial = "<p=1;
}
else if(n==13)
{
cout<<"Factorial = 6227020";
z=800;
cout<
}
else
{
cout<<"Sorry, out of range"<}
}
}