#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int num,i,fact=1;
cout<<"Enter the number "<<endl;
cin>>num;
if ((num==1)||(num<=10))
{
for(i=num;i>1;i--)
{
fact*=i; //factorial formula
}
cout<< "factorial of " <<num<<"="<<fact<<endl;
}
else
cout<<"your enter number= " << num << "is invalid"<<endl;
system("pause");
return 0;
0 comments:
Post a Comment