Write a program to find the fictorial.
#include<iostream>
using namespace std;
int main()
{
long unsigned int fact=1;
int n;
cout<<"Enter a number : ";
cin>>n;
cout<<"Factorial of "<<n;
if(n==0)
{
fact=1;
}
else
{
do
{
fact=n*fact;
n=n-1;
}while(n>0);
}
cout<<" = "<<fact;
}
Comments
Leave a comment