Factorial of number in C++

#include<iostream>
using namespace std;

class factorial{
    public:
    int fact_of_n(int n) {
        int f = 1;
        for(int i = 1; i <= n; i++){
            f *= i;
        }
        cout<<"factorial of: "<<n<<" is: "<<f<<endl;
    }
};

int main(){

    int n;
    cout<<"Find Factorial\n\n";
    cout<<"enter a number: ";
    cin>> n;
    factorial fact;
    fact.fact_of_n(n);
}






Comments

Popular posts from this blog

AI and Human Evolution

To Do List App (GUI) using C#

Snake Game using JAVA