#include<iostream.h>
#include<conio.h>
static double fact=1.0; // Global Value
double factorial(int n)
{
int i=1;
while(i<=n)
{
fact=fact*i;
i++;
}
return fact;
}
int main()
{
clrscr();
int n;
cout<<"Enter a number: ";
cin>>n;
cout<<"The factorial is: "<<factorial(n);
getch();
return 0;
}
#include<conio.h>
static double fact=1.0; // Global Value
double factorial(int n)
{
int i=1;
while(i<=n)
{
fact=fact*i;
i++;
}
return fact;
}
int main()
{
clrscr();
int n;
cout<<"Enter a number: ";
cin>>n;
cout<<"The factorial is: "<<factorial(n);
getch();
return 0;
}