Answer to Question #326867 in C++ for ayz

Question #326867

write a program to add three find factorial using class


1
Expert's answer
2022-04-11T07:45:05-0400
#include<iostream>
using namespace std;

class Test {

public:
    int factorial(int x) {
        int i, f = 1;
        for (i = 1; i <= x; i++) {
            f = f*i;
        }
        return f;
    }
};

int main() {

    int x, f;

    cout << "Enter a number:";
    cin >> x;

    Test obj;
    f = obj.factorial(x);

    cout << "Factorial is:" << f;

    return 0;
}

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
APPROVED BY CLIENTS