C++ Code To Find Factorial Of A Number .


C++  Code To Find The Factorial Of  A  Number
=====================================

#include <iostream>
using namespace std;
int main()
{

    int any;
    cout<<"*********  Factorials ************"<<endl;
    cout<<"\nEnter 1 to Preceed or 0 to exit : "<<endl;
    cin>>any;
    if(any!=0)
    {
        do
        {
            int a,b=1;
            cout<<"\nEnter the number to find the factorial of : "<<endl;
            cin>>a;
            for(int i=1; i<=a; i++)
            {
                b=b*i;
            }
            cout<<"\nThe factorial of the number is : "<<b<<endl;

            cout<<"\n======================================"<<endl;
            cout<<"\nEnter 1 to Preceed or 0 to exit : "<<endl;
            cin>>any;
        }
        while(any!=0);
    }
}

No comments:

Post a Comment