Answer to Question #199992 in C++ for Shaheer

Question #199992

Write a program to find the fictorial.


1
Expert's answer
2021-05-28T10:31:25-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog